Exemplo n.º 1
0
 def deal_event(self, event):
     if event.name == "TurnStart":
         self.host.emit(
             Event(
                 "Refresh", {
                     "camp":
                     self.host.player_list[
                         self.host.current_player_id].camp,
                     "turn":
                     self.host.turn_count
                 }, 4))
         self.host.emit(Event("CheckBarrack", {}, 4))
         self.host.emit(Event("NewTurn", {}, 4))
Exemplo n.º 2
0
 def deal_event(self, event):
     if event.name == "Attack":
         if event.parameter_dict["source"] == self.host:
             self.host.emit(Event("Attacking", event.parameter_dict))
             self.host.emit(
                 Event(
                     "Damage", {
                         "source": event.parameter_dict["source"],
                         "target": event.parameter_dict["target"],
                         "damage": event.parameter_dict["source"].atk,
                         "type": "Attack"
                     }))
             self.host.emit(Event("Attacked", event.parameter_dict))
             self.host.emit(Event("CheckDeath", priority=4))
Exemplo n.º 3
0
 def deal_event(self,event):
     if event.name == "TurnStart" and self.host.host.state_system.current_player_id == self.host.host.camp \
         and not self.host.host.holy_shield:
         self.host.emit(Event("BuffAdd",{
             "source": self.host.host,
             "type": "HolyShield"
         },-1))
Exemplo n.º 4
0
 def act(self):
     self.parser.attacked.append(self.attacker.id)
     self.map.emit(
         Event("Attack", {
             "source": self.attacker,
             "target": self.target
         }))
     self.map.start_event_processing()
Exemplo n.º 5
0
 def deal_event(self, event):
     if event.name == "Move":
         if event.parameter_dict["source"] == self.host:
             self.host.emit(
                 Event(
                     "Leave", {
                         "source": event.parameter_dict["source"],
                         "pos": event.parameter_dict["source"].pos
                     }))
             self.host.pos = event.parameter_dict["dest"]
             self.host.emit(
                 Event(
                     "Arrive", {
                         "source": event.parameter_dict["source"],
                         "pos": event.parameter_dict["source"].pos
                     }))
             self.host.emit(Event("UpdateRingBuff", priority=3))
Exemplo n.º 6
0
 def buff(self):
     self.host.max_hp += ARTIFACTS["SalamanderShield"]["hp_up"]
     self.host.hp += ARTIFACTS["SalamanderShield"]["hp_up"]
     if not self.host.holy_shield:
         self.state_system.emit(Event("BuffAdd",{
                 "source": self.host,
                 "type": "HolyShield"
             },1))
Exemplo n.º 7
0
 def act(self):
     self.parser.moved.append(self.mover.id)
     self.map.emit(
         Event("Move", {
             "source": self.mover,
             "dest": self.position
         }))
     self.map.start_event_processing()
Exemplo n.º 8
0
 def act(self):
     self.map.emit(
         Event(
             "ActivateArtifact", {
                 "camp": self.player_id,
                 "name": self.artifact.name,
                 "target": self.target
             }))
     self.map.start_event_processing()
Exemplo n.º 9
0
 def effect(self,target):
     for unit in self.state_system.map.unit_list:
         if calculator.cube_distance(unit.pos,target) <= ARTIFACTS[self.name]["affect_range"] \
             and unit.camp != self.camp:
             self.emit(Event("Damage",{
                 "source": self,
                 "target": unit,
                 "damage": ARTIFACTS[self.name]["damage"],
                 "type": "InfernoFlameActivate"
             },-3))
     self.emit(Event("Summon",{
         "type": ARTIFACTS[self.name]["summon"],
         "level": 1,
         "pos": target,
         "camp": self.camp,
         "artifact_host": self
     }))
     self.emit(Event("CheckDeath",priority=4))
Exemplo n.º 10
0
 def act(self):
     self.map.emit(
         Event(
             "Summon", {
                 "type": self.type,
                 "level": self.level,
                 "pos": self.position,
                 "camp": self.player_id
             }))
     self.map.start_event_processing()
Exemplo n.º 11
0
 def deal_event(self, event):
     if event.name == "Damage":
         if event.parameter_dict["target"] == self.host:
             hp_loss = min(self.host.hp, event.parameter_dict["damage"])
             self.host.hp -= event.parameter_dict["damage"]
             self.host.emit(
                 Event("MiracleHurt", {
                     "source": self.host,
                     "hp_loss": hp_loss
                 }))
Exemplo n.º 12
0
 def delete(self):
     self.host.buff_list.remove(self)
     self.state_system.emit(
         Event("BuffRemove", {
             "source": self.host,
             "type": self.type
         }))
     self.debuff()
     self.host = None
     self.event_listener_list = []
Exemplo n.º 13
0
 def add_on(self, host):
     # host is a unit
     self.host = host
     host.buff_list.append(self)
     self.state_system.emit(
         Event("BuffAdd", {
             "source": self.host,
             "type": self.type
         }))
     self.buff()
Exemplo n.º 14
0
 def set_round(self, _round):
     '''
     update round
     '''
     self.summoned = []
     self.moved = []
     self.attacked = []
     self.round = _round
     self.map.emit(Event("TurnStart"))
     self.map.start_event_processing()
Exemplo n.º 15
0
 def act(self):
     self.map.emit(
         Event(
             "GameStart", {
                 "camp": int(self.player_id),
                 "cards": {
                     "artifacts": self.artifacts,
                     "creatures": self.creatures
                 }
             }))
     self.map.start_event_processing()
Exemplo n.º 16
0
 def effect(self,target):
     for unit in self.state_system.map.unit_list:
         if calculator.cube_distance(unit.pos,target) <= ARTIFACTS["HolyLight"]["affect_range"] \
             and unit.camp == self.camp:
             self.emit(Event("Heal",{
                 "source": self,
                 "target": unit,
                 "heal": unit.max_hp
             },-1))
             new_buff = HolyLightAtkBuff(self.state_system)
             new_buff.add_on(unit)
     self.recycle()
Exemplo n.º 17
0
 def deal_event(self, event):
     if event.name == "Damage":
         if event.parameter_dict["target"] == self.host:
             if self.host.holy_shield and event.parameter_dict[
                     "damage"] != 0:
                 event.parameter_dict["damage"] = 0
                 self.host.emit(
                     Event("BuffRemove", {
                         "source": self.host,
                         "type": "HolyShield"
                     }, -1))
             self.host.hp -= event.parameter_dict["damage"]
Exemplo n.º 18
0
 def deal_event(self, event):
     if event.name == "Summon":
         unit = None
         if event.parameter_dict["type"] == "Archer":
             unit = Archer(event.parameter_dict["camp"],
                           event.parameter_dict["level"],
                           event.parameter_dict["pos"], self.host)
         elif event.parameter_dict["type"] == "Swordsman":
             unit = Swordsman(event.parameter_dict["camp"],
                              event.parameter_dict["level"],
                              event.parameter_dict["pos"], self.host)
         elif event.parameter_dict["type"] == "BlackBat":
             unit = BlackBat(event.parameter_dict["camp"],
                             event.parameter_dict["level"],
                             event.parameter_dict["pos"], self.host)
         elif event.parameter_dict["type"] == "Priest":
             unit = Priest(event.parameter_dict["camp"],
                           event.parameter_dict["level"],
                           event.parameter_dict["pos"], self.host)
         elif event.parameter_dict["type"] == "VolcanoDragon":
             unit = VolcanoDragon(event.parameter_dict["camp"],
                                  event.parameter_dict["level"],
                                  event.parameter_dict["pos"], self.host)
         elif event.parameter_dict["type"] == "Inferno":
             unit = Inferno(event.parameter_dict["camp"],
                            event.parameter_dict["level"],
                            event.parameter_dict["pos"], self.host,
                            event.parameter_dict["artifact_host"])
         elif event.parameter_dict["type"] == "FrostDragon":
             unit = FrostDragon(event.parameter_dict["camp"],
                                event.parameter_dict["level"],
                                event.parameter_dict["pos"], self.host)
         if unit:
             self.host.map.add_unit(unit)
             self.host.emit(
                 Event("Spawn", {
                     "source": unit,
                     "pos": unit.pos
                 }))
             self.host.emit(Event("UpdateRingBuff", priority=3))
Exemplo n.º 19
0
 def deal_event(self, event):
     if event.name == "TurnEnd" and self.host.state_system.current_player_id == self.host.camp:
         for unit in self.host.state_system.map.unit_list:
             if calculator.cube_distance(unit.pos,self.host.pos) <= UNIT_DATA["Priest"]["heal_range"][self.host.level-1] \
                 and unit.camp == self.host.camp:
                 self.host.emit(
                     Event(
                         "Heal", {
                             "source":
                             self.host,
                             "target":
                             unit,
                             "heal":
                             UNIT_DATA["Priest"]["heal"][self.host.level -
                                                         1]
                         }, -3))
Exemplo n.º 20
0
 def deal_event(self, event):
     if event.name == "Attacked":
         if event.parameter_dict["target"] == self.host:
             distance = calculator.cube_distance(
                 event.parameter_dict["source"].pos,
                 event.parameter_dict["target"].pos,
             )
             if self.host.atk_range[0] <= distance <= self.host.atk_range[1] and \
                 (not event.parameter_dict["source"].flying or self.host.atk_flying) and \
                 self.host.atk != 0:
                 self.host.emit(
                     Event(
                         "Damage", {
                             "source": event.parameter_dict["target"],
                             "target": event.parameter_dict["source"],
                             "damage": event.parameter_dict["target"].atk,
                             "type": "AttackBack"
                         }))
Exemplo n.º 21
0
 def deal_event(self, event):
     if event.name == "Attacked":
         if event.parameter_dict["source"] == self.host and\
             event.parameter_dict["target"].type != "Miracle":
             for unit in self.host.state_system.map.unit_list:
                 if (calculator.cube_distance(unit.pos,self.host.pos) == UNIT_DATA["VolcanoDragon"]["self_range"] and
                     calculator.cube_distance(unit.pos,event.parameter_dict["target"].pos) == UNIT_DATA["VolcanoDragon"]["target_range"]) and \
                     unit.camp != self.host.camp and not unit.flying:
                     self.host.emit(
                         Event("Damage", {
                             "source":
                             self.host,
                             "target":
                             unit,
                             "damage":
                             UNIT_DATA["VolcanoDragon"]["splash_damage"][
                                 self.host.level - 1],
                             "type":
                             "VolcanoDragonSplash"
                         },
                               priority=-1))
Exemplo n.º 22
0
 def deal_event(self, event):
     if event.name == "CheckDeath":
         for unit in self.host.map.unit_list:
             if unit.hp <= 0 and not unit.death_flag:
                 unit.death_flag = True
                 self.host.emit(Event("Death", {"source": unit}))
Exemplo n.º 23
0
 def act(self):
     self.map.emit(Event("TurnEnd"))
     self.map.start_event_processing()