def sync(self, data): # this only executes at client side, let it crash. if data['sync_id'] != self.sync_id: logging.error( 'CardOOS: server: %s, %s, %s, sync_id=%d; client: %s, %s, %s, sync_id=%d', data['type'], self.SUIT_REV.get(data['suit'], data['suit']), self.NUM_REV.get(data['number'], data['number']), data['sync_id'], self.__class__.__name__, self.SUIT_REV.get(self.suit), self.NUM_REV.get(self.number), self.sync_id, ) raise GameError('Card: out of sync') clsname = data['type'] cls = Card.card_classes.get(clsname) if not cls: raise GameError('Card: unknown card class') self.__class__ = cls self.suit = data['suit'] self.number = data['number'] self.track_id = data['track_id']
def apply_action(self): g = Game.getgame() card = self.card target_list = self.target_list if not card: return False # special case for debug from .cards import HiddenCard if card.is_card(HiddenCard): raise GameError('launch hidden card') # ---------------------- action = card.associated_action if not getattr(card, 'no_drop', False): g.process_action(DropUsedCard(self.source, cards=[card])) if action: target = target_list[0] if target_list else self.source a = action(source=self.source, target=target) self.card_action = a a.associated_card = card a.target_list = target_list a.force_fire() # For Exinwan, see UserAction.force_fire g.process_action(a) return True return False
def apply_action(self): ft = self.ftact tgt = ft.target from .definition import YinYangOrbCard for e in tgt.equips: if e.is_card(YinYangOrbCard): g = Game.getgame() g.process_action(DropCards(tgt, [e])) ft.set_card(e) break else: raise GameError('Player has YinYangOrb skill but no equip!') return True
def apply_action(self): ft = self.ftact tgt = ft.target from .definition import YinYangOrbCard for e in tgt.equips: if e.is_card(YinYangOrbCard): with MigrateCardsTransaction(self) as trans: migrate_cards([ft.card], tgt.cards, unwrap=True, trans=trans, is_bh=True) detach_cards([e], trans=trans) self.card = e ft.set_card(e, self) break else: raise GameError('Player has YinYangOrb skill but no equip!') return True