Skip to content

Commit

Permalink
Normalized models
Browse files Browse the repository at this point in the history
  • Loading branch information
taslimisina committed Feb 3, 2020
1 parent dadeb79 commit 6708e15
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,15 @@ def get_value(string):


class Spell:
def __init__(self, type, type_id, duration, priority, target):
self.type = SpellType.get_value(type)
def __init__(self, type, type_id, duration, priority, target, range, power, is_damaging):
self.type = type
self.type_id = type_id
self.duration = duration
self.priority = priority
self.target = SpellTarget.get_value(target)
self.target = target
self.range = range
self.power = power
self.is_damaging = is_damaging

def is_unit_spell(self):
return self.type == SpellType.TELE
Expand Down Expand Up @@ -222,34 +225,29 @@ def __init__(self, turn, type, info):


class CastSpell:
def __init__(self, type_id, caster_id, remaining_turns, was_cast_this_turn, affected_units):
self.type_id = type_id
def __init__(self, spell, id, caster_id, cell, affected_units):
self.spell = spell
self.id = id
self.caster_id = caster_id
self.remaining_turns = remaining_turns
self.was_cast_this_turn = was_cast_this_turn
self.cell = cell
self.affected_units = affected_units


class CastUnitSpell(CastSpell):
def __init__(self, type_id, caster_id, remaining_turns, was_cast_this_turn, affected_units
, target_cell, unit_id, path_id):
super().__init__(type_id=type_id, caster_id=caster_id,
remaining_turns=remaining_turns,
was_cast_this_turn=was_cast_this_turn,
affected_units=affected_units)
self.target_cell = target_cell
self.unit_id = unit_id
self.path_id = path_id
def __init__(self, spell, id, caster_id, cell, affected_units
, unit, path):
super().__init__(spell=spell, id=id, caster_id=caster_id,
cell=cell, affected_units=affected_units)
self.unit = unit
self.path = path


class CastAreaSpell(CastSpell):
def __init__(self, type_id, caster_id, remaining_turns, was_cast_this_turn, center, affected_units):
super().__init__(type_id=type_id, caster_id=caster_id,
remaining_turns=remaining_turns,
was_cast_this_turn=was_cast_this_turn,
affected_units=affected_units)
self.center = center
self.affected_units = affected_units
def __init__(self, spell, id, caster_id, cell, affected_units,
remaining_turns):
super().__init__(spell=spell, id=id, caster_id=caster_id,
cell=cell, affected_units=affected_units)
self.ramaining_turns = remaining_turns


class ServerConstants:
Expand All @@ -276,7 +274,8 @@ class ServerConstants:

class GameConstants:
def __init__(self, max_ap, max_turns, turn_timeout, pick_timeout,
turns_to_upgrade, turns_to_spell, damage_upgrade_addition, range_upgrade_addition):
turns_to_upgrade, turns_to_spell, damage_upgrade_addition, range_upgrade_addition,
deck_size, hand_size):
self.max_ap = max_ap
self.max_turns = max_turns
self.turn_timeout = turn_timeout
Expand All @@ -285,6 +284,9 @@ def __init__(self, max_ap, max_turns, turn_timeout, pick_timeout,
self.turns_to_spell = turns_to_spell
self.damage_upgrade_addition = damage_upgrade_addition
self.range_upgrade_addition = range_upgrade_addition
self.deck_size = deck_size
self.hand_size = hand_size

# if World.DEBUGGING_MODE:
# import datetime
# World.LOG_FILE_POINTER = open('client' + '-' +
Expand Down

0 comments on commit 6708e15

Please sign in to comment.