Changeset 85


Ignore:
Timestamp:
01/06/11 20:58:00 (10 years ago)
Author:
atzm
Message:

support to make warrior by parameters

Location:
pycodebattler/trunk/pycodebattler
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pycodebattler/trunk/pycodebattler/battle.py

    r71 r85  
    133133    ]] 
    134134    players = [ 
    135         pycodebattler.warrior.Warrior( 
     135        pycodebattler.warrior.Warrior.make( 
    136136            pycodebattler.util.path2name(f), 
    137137            open(f), 
  • pycodebattler/trunk/pycodebattler/scouter.py

    r71 r85  
    2020def _main_entry(): 
    2121    if len(sys.argv) == 1: 
    22         p = [pycodebattler.warrior.Warrior('stdin', sys.stdin)] 
     22        p = [pycodebattler.warrior.Warrior.make('stdin', sys.stdin)] 
    2323    else: 
    24         p = [pycodebattler.warrior.Warrior( 
     24        p = [pycodebattler.warrior.Warrior.make( 
    2525             pycodebattler.util.path2name(f), open(f)) 
    2626             for f in sys.argv[1:]] 
  • pycodebattler/trunk/pycodebattler/warrior.py

    r71 r85  
    6464 
    6565class Warrior: 
    66     def __init__(self, name, fp, skill_list=[], luck_range=5000): 
    67         scorer = pycodebattler.score.Scorer(fp.readlines()) 
    68  
    69         self._luck_range = luck_range 
     66    def __init__(self, name, hitpoint, skillpoint, strength, concentration, 
     67                 defense, agility, luck, skill_list=[], luck_range=5000): 
    7068        self._name = name 
    7169        self._skill_list = {} 
    72         self._max_hitpoint = self._hitpoint = scorer.style_score() 
    73         self._max_skillpoint = self._skillpoint = scorer.name_score() 
    74         self._strength = scorer.complex_score() 
    75         self._concentration = scorer.colon_score() 
    76         self._defense = scorer.lines_score() 
    77         self._agility = scorer.const_score() 
    78         self._luck = luck_range // (self.hitpoint() + 
    79                                     self.skillpoint() + 
    80                                     self.strength() + 
    81                                     self.concentration() + 
    82                                     self.defense() + 
    83                                     self.agility()) 
     70        self._max_hitpoint = self._hitpoint = hitpoint 
     71        self._max_skillpoint = self._skillpoint = skillpoint 
     72        self._strength = strength 
     73        self._concentration = concentration 
     74        self._defense = defense 
     75        self._agility = agility 
     76        self._luck = luck 
     77        self._luck_range = luck_range 
    8478 
    8579        for sk in skill_list: 
    8680            self._skill_list[sk.name()] = sk 
     81 
     82    @classmethod 
     83    def make(klass, name, fp, skill_list=[], luck_range=5000): 
     84        scorer = pycodebattler.score.Scorer(fp.readlines()) 
     85 
     86        hitpoint = scorer.style_score() 
     87        skillpoint = scorer.name_score() 
     88        strength = scorer.complex_score() 
     89        concentration = scorer.colon_score() 
     90        defense = scorer.lines_score() 
     91        agility = scorer.const_score() 
     92        luck = luck_range // (hitpoint + skillpoint + strength + 
     93                              concentration + defense + agility) or 1 
     94 
     95        return klass(name, hitpoint, skillpoint, strength, concentration, 
     96                     defense, agility, luck, skill_list, luck_range) 
    8797 
    8898    def __str__(self): 
Note: See TracChangeset for help on using the changeset viewer.