def situationF5(m_room: str, e_room: str): game_num = ID[m_room] game: Game = game_list[game_num] d = { "user_1": { "id": game.p_name0, "name": game.p_name0, "hand": card_to_json(game.player[0].hand.card_list), "deck": card_to_json(game.player[0].deck.card_list), "cemetery": card_to_json(game.player[0].cemetery.card_list), "barrier": card_to_json(game.player[0].field.barrier), "soldier": card_to_json(game.player[0].field.soldier) }, "user_2": { "id": game.p_name1, "name": game.p_name1, "hand": card_to_json(game.player[1].hand.card_list), "deck": card_to_json(game.player[1].deck.card_list), "cemetery": card_to_json(game.player[1].cemetery.card_list), "barrier": card_to_json(game.player[1].field.barrier), "soldier": card_to_json(game.player[1].field.soldier) } } emit("situation", d, room=e_room)
def situation(data): game_num = ID[data["name"]] # print(game_list[game_num].p_name0) # print(game_list[game_num].p_name1) game: Game = game_list[game_num] emit("situation", { "user_1": { "id": game.p_name0, "name": game.p_name0, "hand": card_to_json(game.player[0].hand.card_list), "deck": card_to_json(game.player[0].deck.card_list), "cemetery": card_to_json(game.player[0].cemetery.card_list), "barrier": [], "soldier": [] }, "user_2": { "id": game.p_name1, "name": game.p_name1, "hand": card_to_json(game.player[1].hand.card_list), "deck": card_to_json(game.player[1].deck.card_list), "cemetery": card_to_json(game.player[1].cemetery.card_list), "barrier": [], "soldier": [] } }, room=data["name"])
def attack(data): game_num = ID[data["name"]] room_name = get_keys_from_value(ID, game_num, data["name"])[0] print(data) game: Game = game_list[game_num] if game.player[game.turn_player].can_attack: game.attack(data["lengths"]) print(game.battler) emit("attack", card_to_json(game.battler), room=room_name) else: emit("notAttacable", room=data["name"]) situationF5(room_name, data["name"])
def set_barrier(data): game_num = ID[data["name"]] room_name = get_keys_from_value(ID, game_num, data["name"])[0] game: Game = game_list[game_num] emit("setBarrier", { "card": card_to_json( game.player[game.turn_player].hand.card_list[data["handLength"]]) }, room=room_name) emit("damage", 1, room=room_name) emit("handDecrease", {"len": data["handLength"]}, room=room_name) game.set_barrier(data["handLength"]) judge(game_num, room_name, data["name"]) situationF5(room_name, data["name"])
def summon(data: dict): game_num = ID[data["name"]] room_name = get_keys_from_value(ID, game_num, data["name"])[0] game: Game = game_list[game_num] emit("summon", { "card": card_to_json( game.player[game.turn_player].hand.card_list[data["handLength"]]) }, room=room_name) print(game.player[game.turn_player].hand.card_list) # print(data.keys()) if "costLength" in data: game.summon_magician(data["handLength"], data["costLength"], data["barrierLength"]) emit("driveBarrier", data["barrierLength"], room=room_name) emit("handDecrease", {"len": data["costLength"]}, room=room_name) elif "barrierLength" in data: if isinstance(data["barrierLength"], list) and len( data["barrierLength"]) == 2: game.summon_hero(data["handLength"], data["barrierLength"][0], data["barrierLength"][1]) emit("driveBarrier", data["barrierLength"][0], room=room_name) emit("driveBarrier", data["barrierLength"][1], room=room_name) else: # print(data["barrierLength"]) game.summon_soldier(data["handLength"], data["barrierLength"]) emit("driveBarrier", data["barrierLength"], room=room_name) emit("damage", 1, room=room_name) else: game.summon_ace(data["handLength"]) emit("damage", 1, room=room_name) judge(game_num, room_name, data["name"]) print(game.player[game.turn_player].hand.card_list) emit("handDecrease", {"len": data["handLength"]}, room=room_name) situationF5(data["name"], room_name)