CPlayer.java :  » Java-2D » fgen2d » fgen » Java Open Source

Java Open Source » Java 2D » fgen2d 
fgen2d » fgen » CPlayer.java
/*
 * football player definition
 */

package fgen;

/**
 *
 * @author Oleg Rachaev
 */
public class CPlayer {
            //player data
        public int p_id;
        public int num;  //squard number
        public int name; //
        public int pos;  //position/amplua
        public int exp;  //experiance
        public int pow;  //overall player strench
        public int stam; //stamina - for local action(fast runs and etc) (changes during match)
        public int hlth;  //health
        public int physCond; //physical/condition before the match(current)(changes during match)
        public int mrlCond; //psycho/morale condition before the match(current)(changes during match)
            //player characteristic
        public int acc;     //acceleration
        public int spd;     //speed
        public int shotPwr; //shot power
        public int shotAcc; //shot accurracy
        public int tech;    //technics
        public int mrk;     //marking - defense ability
        public int head;    //head play ability
        public int drbl;    //driblling
        //TODO add to file format
        public int pass;  //
        public int coord;//coordinance
                
    public CPlayer() {
        
    }
    public CPlayer( String theParamsStr ) {
        loadFromString( theParamsStr );
    }
//    public CPlayer( String thePlayerPropsFile ) {
//        load( thePlayerPropsFile );
//    }
    public void loadFromString( String theParamsStr ) {
        String ss[] = theParamsStr.split(" ");
        p_id = Integer.parseInt( ss[0] );
        num = Integer.parseInt( ss[1] );
        name = Integer.parseInt( ss[2] );
        pos = Integer.parseInt( ss[3] );
        exp = Integer.parseInt( ss[4] );
        pow = Integer.parseInt( ss[5] );
        stam = Integer.parseInt( ss[6] );
        hlth = Integer.parseInt( ss[7] );
        physCond = Integer.parseInt( ss[8] );
        mrlCond = Integer.parseInt( ss[9] );
        acc = Integer.parseInt( ss[10] );
        spd = Integer.parseInt( ss[11] );
        shotPwr = Integer.parseInt( ss[12] );
        shotAcc = Integer.parseInt( ss[13] );
        tech = Integer.parseInt(ss[14] );
        mrk = Integer.parseInt(ss[15] );
        head = Integer.parseInt( ss[16] );
        drbl = Integer.parseInt( ss[17] );
        pass = Integer.parseInt(ss[18]);
        coord = Integer.parseInt(ss[19]);
    }

    public String writeToStr()  {
        String res =
              String.valueOf(p_id)+ " " +
              String.valueOf(num)+ " " +
              String.valueOf(name)+ " " +
              String.valueOf(pos)+ " " +
              String.valueOf(exp)+ " " +
              String.valueOf(pow)+ " " +
              String.valueOf(stam)+ " " +
              String.valueOf(hlth)+ " " +
              String.valueOf(physCond)+ " " +
              String.valueOf(mrlCond)+ " " +
              String.valueOf(acc)+ " " +
              String.valueOf(spd)+ " " +
              String.valueOf(shotPwr)+ " " +
              String.valueOf(shotAcc)+ " " +
              String.valueOf(tech)+ " " +
              String.valueOf(mrk)+ " " +
              String.valueOf(head)+ " " +
              String.valueOf(drbl)+ " " +
              String.valueOf(pass)+ " " +
              String.valueOf(coord);
        return res;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.