project_files/Android-build/SDL-android-project/src/org/hedgewars/mobile/EngineProtocol/Weapon.java
author Xeli
Sun, 21 Aug 2011 16:25:18 +0200
branchhedgeroid
changeset 5621 ea796c83ea47
parent 5508 dcf1b3645af6
permissions -rw-r--r--
added licenses
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5621
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     1
/*
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     2
 * Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     3
 * Copyright (c) 2011 Richard Deurwaarder <xeli@xelification.com>
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     4
 *
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     8
 *
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    12
 * GNU General Public License for more details.
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    13
 *
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    14
 * You should have received a copy of the GNU General Public License
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    15
 * along with this program; if not, write to the Free Software
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    17
 */
ea796c83ea47 added licenses
Xeli
parents: 5508
diff changeset
    18
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    19
package org.hedgewars.mobile.EngineProtocol;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    20
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    21
import java.io.BufferedReader;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    22
import java.io.File;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    23
import java.io.FileNotFoundException;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    24
import java.io.FileReader;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    25
import java.io.IOException;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    26
import java.util.ArrayList;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    27
import java.util.Arrays;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    28
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    29
import org.xmlpull.v1.XmlPullParser;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    30
import org.xmlpull.v1.XmlPullParserException;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    31
import org.xmlpull.v1.XmlPullParserFactory;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    32
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    33
import android.content.Context;
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    34
import android.os.Parcel;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    35
import android.os.Parcelable;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    36
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    37
public class Weapon implements Parcelable{
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    38
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    39
	public static final String DIRECTORY_WEAPON = "weapons";
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    40
	
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    41
	private String name;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    42
	private String QT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    43
	private String prob;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    44
	private String delay;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    45
	private String crate;
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    46
	private static int maxWeapons;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    47
	
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    48
	static{
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    49
		//maxWeapons = PascalExports.HWgetNumberOfWeapons();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    50
	}
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    51
	
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    52
	public Weapon(String _name, String _QT, String _prob, String _delay, String _crate){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    53
		name = _name;
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    54
		
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    55
		//Incase there's a newer ammoStore which is bigger we append with zeros
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    56
		StringBuffer sb = new StringBuffer();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    57
		while(_QT.length() + sb.length() < maxWeapons){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    58
			sb.append('0');
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    59
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    60
		
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    61
		QT = String.format("e%s %s%s", "ammloadt", _QT, sb);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    62
		prob = String.format("e%s %s%s", "ammprob", _prob, sb);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    63
		delay = String.format("e%s %s%s", "ammdelay", _delay, sb);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    64
		crate = String.format("e%s %s%s", "ammreinf", _crate, sb);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    65
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    66
	
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    67
	public Weapon(Parcel in){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    68
		readFromParcel(in);
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    69
	}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    70
	
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    71
	public String toString(){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    72
		return name;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    73
	}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    74
	
5508
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    75
	public void sendToEngine(EngineProtocolNetwork epn, int teamsCount) throws IOException{
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    76
		epn.sendToEngine(QT);//command prefix is already in string 
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    77
		epn.sendToEngine(prob);
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    78
		epn.sendToEngine(delay);
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    79
		epn.sendToEngine(crate);
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    80
		
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    81
		for(int i = 0; i < teamsCount; i++){
5508
dcf1b3645af6 Fixed IPC provide gameconfig
Xeli
parents: 5463
diff changeset
    82
			epn.sendToEngine("eammstore");
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    83
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    84
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    85
	
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    86
	public static final int STATE_START = 0;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    87
	public static final int STATE_ROOT = 1;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    88
	public static final int STATE_NAME = 2;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    89
	public static final int STATE_QT = 3;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    90
	public static final int STATE_PROBABILITY = 4;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    91
	public static final int STATE_DELAY = 5;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    92
	public static final int STATE_CRATE = 6;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    93
	
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
    94
	public static ArrayList<Weapon> getWeapons(Context c) throws IllegalArgumentException{
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    95
		String dir = c.getFilesDir().getAbsolutePath() + '/' + DIRECTORY_WEAPON + '/';
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    96
		String[] files = new File(dir).list();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    97
		if(files == null) files = new String[]{};
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    98
		Arrays.sort(files);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
    99
		
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   100
		ArrayList<Weapon> weapons = new ArrayList<Weapon>();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   101
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   102
		try {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   103
			XmlPullParserFactory xmlPullFactory = XmlPullParserFactory.newInstance();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   104
			XmlPullParser xmlPuller = xmlPullFactory.newPullParser();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   105
			
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   106
			for(String file : files){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   107
				BufferedReader br = new BufferedReader(new FileReader(dir + file), 1024);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   108
				xmlPuller.setInput(br);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   109
				String name = null;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   110
				String qt = null;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   111
				String prob = null;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   112
				String delay = null;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   113
				String crate = null;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   114
				
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   115
				int eventType = xmlPuller.getEventType();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   116
				int state = STATE_START;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   117
				while(eventType != XmlPullParser.END_DOCUMENT){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   118
					switch(state){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   119
					case STATE_START:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   120
						if(eventType == XmlPullParser.START_TAG && xmlPuller.getName().equals("weapon")) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   121
						else if(eventType != XmlPullParser.START_DOCUMENT) throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   122
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   123
					case STATE_ROOT:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   124
						if(eventType == XmlPullParser.START_TAG){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   125
							if(xmlPuller.getName().toLowerCase().equals("qt")) state = STATE_QT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   126
							else if(xmlPuller.getName().toLowerCase().equals("name")) state = STATE_NAME;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   127
							else if(xmlPuller.getName().toLowerCase().equals("probability")) state = STATE_PROBABILITY;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   128
							else if(xmlPuller.getName().toLowerCase().equals("delay")) state = STATE_DELAY;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   129
							else if(xmlPuller.getName().toLowerCase().equals("crate")) state = STATE_CRATE;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   130
							else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   131
						}else if(eventType == XmlPullParser.END_TAG) state = STATE_START;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   132
						else throwException(xmlPuller.getText(), eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   133
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   134
					case STATE_NAME:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   135
						if(eventType == XmlPullParser.TEXT) name = xmlPuller.getText().trim();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   136
						else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   137
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   138
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   139
					case STATE_QT:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   140
						if(eventType == XmlPullParser.TEXT) qt = xmlPuller.getText().trim();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   141
						else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   142
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   143
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   144
					case STATE_PROBABILITY:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   145
						if(eventType == XmlPullParser.TEXT) prob = xmlPuller.getText().trim();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   146
						else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   147
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   148
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   149
					case STATE_DELAY:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   150
						if(eventType == XmlPullParser.TEXT) delay = xmlPuller.getText().trim();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   151
						else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   152
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   153
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   154
					case STATE_CRATE:
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   155
						if(eventType == XmlPullParser.TEXT) crate = xmlPuller.getText().trim();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   156
						else if(eventType == XmlPullParser.END_TAG) state = STATE_ROOT;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   157
						else throwException(file, eventType);
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   158
						break;
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   159
					}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   160
					eventType = xmlPuller.next();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   161
					while(eventType == XmlPullParser.TEXT && xmlPuller.isWhitespace()){//Skip whitespaces
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   162
						eventType = xmlPuller.next();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   163
					}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   164
				}//end while(eventtype != END_DOCUMENT
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   165
				weapons.add(new Weapon(name, qt, prob, delay, crate));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   166
			}//end for(string file : files
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   167
			return weapons;
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   168
			
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   169
		} catch (XmlPullParserException e) {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   170
			e.printStackTrace();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   171
		} catch (FileNotFoundException e) {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   172
			e.printStackTrace();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   173
		} catch (IOException e) {
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   174
			e.printStackTrace();
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   175
		}
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   176
		return new ArrayList<Weapon>();//TODO handle correctly
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   177
	}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   178
	
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   179
	private static void throwException(String file, int eventType){
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   180
		throw new IllegalArgumentException(String.format("Xml file: %s malformed with eventType: %d.", file, eventType));
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   181
	}
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   182
5463
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   183
	public int describeContents() {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   184
		return 0;
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   185
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   186
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   187
	public void writeToParcel(Parcel dest, int flags) {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   188
		dest.writeString(name);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   189
		dest.writeString(QT);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   190
		dest.writeString(prob);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   191
		dest.writeString(delay);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   192
		dest.writeString(crate);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   193
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   194
	
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   195
	private void readFromParcel(Parcel src){
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   196
		name = src.readString();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   197
		QT = src.readString();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   198
		prob = src.readString();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   199
		delay = src.readString();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   200
		crate = src.readString();
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   201
	}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   202
	
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   203
	public static final Parcelable.Creator<Weapon> CREATOR = new Parcelable.Creator<Weapon>() {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   204
		public Weapon createFromParcel(Parcel source) {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   205
			return new Weapon(source);
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   206
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   207
		public Weapon[] newArray(int size) {
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   208
			return new Weapon[size];
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   209
		}
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   210
		
83c53a80f7ff datastructures for the different aspects of a gameconfiguration
Xeli
parents: 5433
diff changeset
   211
	};
5433
8f82045953c1 Main class files for the start-local-game screen
Xeli
parents:
diff changeset
   212
}