public void initialize_game() { this.game_event_handler = new LOTRGameEventHandler(this); response_is_yes_no = false; waiting_for_player_response = false; EnemyCardResponses.set_game(this); PlayerCardResponses.set_game(this); CardEnablers.set_game(this); cur_player = null; cur_location = null; players = new List <LOTRPlayer>(); staged_cards = new List <EnemyCard>(); encounter_discard_pile = new List <EnemyCard>(); enemy_deck = EnemyCard.PASSAGE_THROUGH_MIRWOOD_ENEMIES(); //Utils.Shuffle(enemy_deck); for (var i = 0; i < num_players; i++) { players.Add(new LOTRPlayer()); } players[0].add_hero(LOTRHero.ARAGORN()); players[0].add_hero(LOTRHero.GLOIN()); players[0].add_hero(LOTRHero.THEODRED()); player_done_engaging = new Dictionary <LOTRPlayer, bool>(); allowing_actions = false; forced_response_after_action = false; times_to_respond = 1; card_to_respond_to = null; times_responded = 0; num_options_to_display = -1; begin_game(); }
public static LocationCard NECROMANCERS_PASS() { LocationCard the_card = new LocationCard("Necromancer's Pass", 3, 2, "Travel: The first player must discard 2 cards from his hand at random to travel here." , "ORC", new List <LOTRGame.TRAITS>() { LOTRGame.TRAITS.STRONGHOLD, LOTRGame.TRAITS.DOL_GULDUR }, "??"); Func <GameArgs, bool> criteria = (GameArgs args) => { LOTRPlayer first_player = args.relevant_player; return(first_player.get_cards_in_hand().Count >= 2); }; the_card.set_travel_criteria(criteria); List <Func <EventArgs, Card, bool> > card_played_criteria = new List <Func <EventArgs, Card, bool> >() { CardEnablers.card_is_me }; the_card.respond_to_event(GameEvent.LOCATION_TRAVELED, PlayerCardResponses.action_maker(card_played_criteria, EnemyCardResponses.necromancers_pass, the_card)); return(the_card); }
void deal_shadow_card_to_players_engaged_enemies(LOTRPlayer player) { disallow_actions(); foreach (var engaged_enemy in player.get_engaged_enemies()) { if (!engaged_enemy.has_shadow_cards()) { if (enemy_deck.Count > 0) { EnemyCard shadow_card = enemy_deck[0]; enemy_deck.RemoveAt(0); shadow_card.set_face_down(); engaged_enemy.add_shadow_card(shadow_card); //todo: highest engagement first //TODO: maybe throw an event for this guy but for now just do this here.... if (engaged_enemy.get_name() == EnemyCard.DOL_GULDUR_BEASTMASTER().get_name()) { EnemyCard shadow_card2 = enemy_deck[0]; enemy_deck.RemoveAt(0); shadow_card2.set_face_down(); engaged_enemy.add_shadow_card(shadow_card2); //todo: highest engagement first } } } } allow_actions_to_be_played(resolve_enemy_attacks); }
public void hero_resource_paid(LOTRPlayer player, LOTRHero hero) { //todo: put in check that player owns hero //TODO: check for neutral, cost of zero if (card_played != null) { if ((card_played.get_resource_type() == hero.get_resource_type()) || (card_played.get_resource_type() == SPHERE_OF_INFLUENCE.NEUTRAL)) { hero.pay_resource(); resources_paid += 1; } if (resources_paid == card_played.get_cost()) { if (card_played.is_attachment()) { Debug.Log("ATTACGHMENT PLAYED"); cur_state = GAMESTATE.CHOOSING_CHARACTER_TO_ATTACH_ATTACHMENT; } else { Debug.Log("CARD PLAYED"); card_has_been_played(player); } } } }
private void card_has_been_played(LOTRPlayer player) { player.play_card(card_played); //game_event_handler.register_cards(new List<PlayerCard>() {card_played}); Debug.Log("CARD HAS BEEN PLAYED#(O$I()*%$U*(GJ$IOG"); if (cur_phase == GAMEPHASE.PLANNING) { game_event_handler.fire_game_event(GameEvent.CARD_PLAYED_KEY, new GameArgs(c: card_played, a: () => { Debug.Log("OK WHY"); cur_state = GAMESTATE.PLAYING_CARDS; card_played = null; allow_actions_to_be_played(); }, p: get_cur_player(), game: this)); } else //playing actions not in planning phase { Debug.Log(cur_state); // cur_state = GAMESTATE.WAITING_FOR_PLAYER_TO_DECIDE_IF_HE_WANTS_TO_USE_ACTIONS; game_event_handler.fire_game_event(GameEvent.CARD_PLAYED_KEY, new GameArgs(c: card_played, a: () => { Debug.Log("Firing this game event CARD PLAYED CALLBACK"); card_played = null; if (forced_response_after_action) { done_responding(); } cur_state = state_before_actions; //allow_actions_to_be_played(); }, p: get_cur_player(), game: this)); } }
public void attacker_chosen(LOTRPlayer player, PlayerCard attacker) { if (!attacker.is_exhausted()) { attacker.exhaust(); attacking_player_cards.Add(attacker); } }
public void player_finished_choosing_attackers(LOTRPlayer player) { foreach (var attacker in attacking_player_cards) { attacker.declared_as_attacker(); } determine_combat_damage_player_attack_enemy_defend(); }
public void card_attached(LOTRPlayer player, PlayerCard character) { Debug.Log("Attached " + card_played.get_name() + " to " + character.get_name()); character.add_attachment((AttachmentCard)card_played); Debug.Log(string.Join(",", character.get_attachments() .Select(array => string.Join(" ", array)))); card_has_been_played(player); }
public void character_committed(LOTRPlayer player, PlayerCard character) { //todo: check that player owns hero character.commit(); game_event_handler.fire_game_event(GameEvent.CARD_COMMITTED_KEY, new GameArgs(c: character)); Debug.Log("Does this actullay wait"); //fire_game_event(player, GameEvent.GAME_EVENT_TYPE.COMMITTED, new GameArgs(c:character)); }
public void player_chose_enemy_to_resolve(LOTRPlayer player, EnemyCard enemy) { disallow_actions(); //todo: check that enemy is engaging player attacking_enemy = enemy; cur_state = GAMESTATE.DECLARING_DEFENDER; allow_actions_to_be_played(); }
void begin_planning_phase() { allow_actions_to_be_played(); new_phase_started(GAMEPHASE.PLANNING); cur_state = GAMESTATE.PLAYING_CARDS; cur_player = players[0]; debug(); }
public static void grim_resolve(EventArgs args) { GameArgs game_args = (GameArgs)args; PlayerCard me = (PlayerCard)game_args.relevant_card; //TODO: make faramir pick a player, but for now theres only one player LOTRPlayer the_player = game_args.relevant_player; Action the_action = () => { the_player.ready_all_exhausted_cards(); }; //TODO: technically just charcter but whatever game.execute_action(the_action); }
public void hero_chosen_to_take_undefended_damage(LOTRPlayer player, LOTRHero hero) { Action callback = () => { cur_player.enemy_attack_resolved(attacking_enemy); resolve_enemy_attacks(); }; card_takes_damage(hero, damage_to_be_dealt, callback); }
public static void gandalf_reduce_threat(EventArgs args) { GameArgs game_args = (GameArgs)args; LOTRPlayer player = game_args.relevant_player; Action the_action = () => { player.increase_threat(-5); }; game.execute_action(the_action); }
void begin_game() { cur_state = GAMESTATE.GAME_START; cur_quest = QuestCard.PASSAGE_THROUGH_MIRKWOOD_1B(); cur_player = players[0]; for (int i = 0; i < 6; i++) { cur_player.draw_card(); //mulligan blah } begin_resource_phase(); }
public GameArgs(Card c = null, int?i = null, Action a = null, LOTRGame game = null, LOTRPlayer p = null, bool?attack_undefended = null, Card secondary_card = null) { relevant_card = c; relevant_int = i; what_to_do_after_event_or_if_no_response = a; g = game; relevant_player = p; this.attack_undefended = attack_undefended; this.secondary_card = secondary_card; }
public static void gandalf_draw_3(EventArgs args) { GameArgs game_args = (GameArgs)args; LOTRPlayer player = game_args.relevant_player; Action the_action = () => { player.draw_card(); player.draw_card(); player.draw_card(); }; game.execute_action(the_action); }
public static bool has_exhausted_allies(EventArgs args, Card me) { GameArgs the_args = (GameArgs)args; LOTRPlayer the_player = the_args.relevant_player; foreach (var card in the_player.get_allies()) { if (card.is_exhausted()) //TODO: or engaged with another player { return(true); } } return(false); }
public static void necromancers_pass(EventArgs args) { GameArgs game_args = (GameArgs)args; Action the_action = () => { LOTRPlayer the_player = game_args.relevant_player; Random rnd = new Random(); the_player.discard_card_at_index(rnd.Next(the_player.get_cards_in_hand().Count)); the_player.discard_card_at_index(rnd.Next(the_player.get_cards_in_hand().Count)); }; game.execute_action(the_action); game_args.what_to_do_after_event_or_if_no_response(); }
public static bool i_am_in_hand(EventArgs args, Card me) { GameArgs the_args = (GameArgs)args; LOTRPlayer the_player = the_args.relevant_player; foreach (var card in the_player.get_cards_in_hand()) { if (card == me) //TODO: or engaged with another player { return(true); } } return(false); }
public static bool i_am_played(EventArgs args, Card me) { GameArgs the_args = (GameArgs)args; if (me != null) { //Debug.Log("CHECKING FOR ME " + me.get_name()); } LOTRPlayer the_player = the_args.relevant_player; List <LOTRHero> heroes = the_player.get_heroes(); List <PlayerCard> allies = the_player.get_allies(); foreach (var hero in heroes) { //Debug.Log("IS " + hero.get_name() + hero.get_uuid() + " ME " + me.get_name() + me.get_uuid()); if (hero == me) { return(true); } if (((PlayerCard)me).is_attachment()) { AttachmentCard attachment_me = (AttachmentCard)me; if (hero.has_attachment(attachment_me)) { return(true); } } } foreach (var ally in allies) { //Debug.Log("IS " + ally.get_name() + ally.get_uuid() + " ME " + me.get_name()+ me.get_uuid()); if (ally == me) { return(true); } if (((PlayerCard)me).is_attachment()) { AttachmentCard attachment_me = (AttachmentCard)me; if (ally.has_attachment(attachment_me)) { return(true); } } } return(false); }
public void player_engage_enemy(LOTRPlayer player, EnemyCard enemy) { disallow_actions(); //TODO: limit to 1 for (var i = 0; i < staged_cards.Count; i++) { if (staged_cards[i] == enemy) { player.engage_enemy(enemy); game_event_handler.fire_game_event(GameEvent.ENEMY_ENGAGED, new GameArgs( c: enemy)); //hopefulyl no callback staged_cards.RemoveAt(i); break; } } //TODO: engage effects allow_actions_to_be_played(); }
public static void sneak_attack(EventArgs args) { GameArgs game_args = (GameArgs)args; Card card_to_respond_to = game_args.relevant_card; PlayerCard the_card = (PlayerCard)game_args.relevant_card; LOTRPlayer the_player = game_args.relevant_player; Action <Card> the_action = (ally_chosen) => { //put ally card in play. flag it with the phase. PlayerCard chosen_card = (PlayerCard)ally_chosen; chosen_card.add_flag(LOTRAbility.ABILITY_FLAGS.SNEAK_ATTACK); the_player.play_card(chosen_card); }; game.wait_for_forced_response(card_to_respond_to: card_to_respond_to, after_responding_with_card: the_action, what_to_do_after_responding: game_args.what_to_do_after_event_or_if_no_response); }
public static void for_gondor(EventArgs args) { GameArgs game_args = (GameArgs)args; PlayerCard me = (PlayerCard)game_args.relevant_card; //TODO: make faramir pick a player, but for now theres only one player LOTRPlayer the_player = game_args.relevant_player; Action the_action = () => { foreach (var hero in game.get_cur_player().get_heroes()) { hero.add_flag(LOTRAbility.ABILITY_FLAGS.FOR_GONDOR); } foreach (var ally in game.get_cur_player().get_allies()) { ally.add_flag(LOTRAbility.ABILITY_FLAGS.FOR_GONDOR); } }; //TODO: technically just charcter but whatever game.execute_action(the_action); }
public void player_played_card(LOTRPlayer player, PlayerCard card) { disallow_actions(); cur_state = GAMESTATE.PAYING_FOR_CARD; resources_paid = 0; card_played = card; Debug.Log("@L$ERK#TJ$KGJM"); if (card_played.get_cost() == 0 && cur_player.has_hero_of_sphere(card.get_sphere())) { if (card_played.is_attachment()) { Debug.Log("ATTACGHMENT PLAYED"); cur_state = GAMESTATE.CHOOSING_CHARACTER_TO_ATTACH_ATTACHMENT; } else { Debug.Log("CARD PLAYED"); card_has_been_played(player); } } }
public static bool has_at_least_one_character_committed(EventArgs args, Card me) { GameArgs the_args = (GameArgs)args; LOTRPlayer the_player = the_args.relevant_player; foreach (var card in the_player.get_heroes()) { if (card.is_committed()) //TODO: or engaged with another player { return(true); } } foreach (var card in the_player.get_allies()) { if (card.is_committed()) //TODO: or engaged with another player { return(true); } } return(false); }
public void player_chose_defender(LOTRPlayer player, PlayerCard defender) { disallow_actions(); if (defender != null && defender.is_exhausted()) { Debug.Log("CANT DEFEND, I AM EXHAUSTED"); return; } if (defender == null) { //TODO: undefended attack_undefended = true; } else { defending_player_card = defender; defending_player_card.declared_as_defender(); Debug.Log("ATTACK DEFENDED BY " + defender.get_name()); attack_undefended = false; } allow_actions_to_be_played(); resolve_shadow_effect(attacking_enemy); }
public void player_chose_enemy_to_attack(LOTRPlayer player, EnemyCard enemy) { defending_enemy = enemy; cur_state = GAMESTATE.DECLARING_ATTACKERS; attacking_player_cards = new List <PlayerCard>(); }
public List <EnemyCard> get_engaged_enemies(LOTRPlayer player) { return(player.get_engaged_enemies()); }
public Dictionary <LOTRHero, int> get_resources(LOTRPlayer player) { return(player.get_resources()); }