Untitled

mail@pastecode.io avatar
unknown
rust
23 days ago
22 kB
5
Indexable
Never

    #[tokio::test]
    async fn test() {


        let mut game = Game::new();

        game.add_player(
            Player::new(
                "Player 1",
                100,
                5,
                vec![
                    Card::new(
                        "Poison",
                        "Applies 2 damage for the next 3 turns after 1 turn.",
                        vec![
                            CardActionTrigger::new(ActionTriggerType::PhaseBased(vec![TurnPhase::Upkeep], TriggerTarget::Owner),
                                Arc::new(CardDamageAction {
                                    target: CardActionTarget::Target
                                })
                            )
                        ],
                        CardPhase::Charging(1),
                        CardType::Artifact,
                        vec![Stat::new(StatType::Damage, 2)],
                        vec![ManaType::Black]
                    ),

                    Card::new(
                        "Swamp",
                        "TAP: Adds 1 Swamp mana to your pool",
                        vec![
                            CardActionTrigger::new(ActionTriggerType::Manual, Arc::new(GenerateManaAction {
                                mana_to_add: vec![ManaType::Black],
                                target: PlayerActionTarget::SelfPlayer,
                            })),
                        ],
                        CardPhase::Ready,
                        CardType::Mana(ManaType::Black),
                        vec![],
                        vec![]
                    ),
                ],
            )
        ).await;
        game.add_player(Player::new("Player 2", 100, 5, vec![
            Card::new(
                "Destroy",
                "Destroy target card",
                vec![
                            CardActionTrigger::new(ActionTriggerType::Instant,
                                Arc::new(DestroyCardAction {})
                            )
                ],
                CardPhase::Charging(1),
                CardType::Instant,
                vec![Stat::new(StatType::Damage, 1)],
                vec![ManaType::Blue]
            ),


            Card::new(
                "Swamp",
                "TAP: Adds 1 Swamp mana to your pool",
                vec![
                    CardActionTrigger::new(ActionTriggerType::Manual, Arc::new(GenerateManaAction {
                        mana_to_add: vec![ManaType::Blue],
                        target: PlayerActionTarget::SelfPlayer,
                    })),
                ],
                CardPhase::Ready,
                CardType::Mana(ManaType::Blue),
                vec![],
                vec![]
            ),
        ])).await;



        game.start_turn(0).await;
        for _ in 0..17 {
            game.advance_turn().await;
        }

        let player = &game.players[0].clone();
        let player2 = &game.players[1].clone();
        let posion_target = EffectTarget::Player(Arc::clone(player2));
        game.play_card(player, 0, None).await.expect("oh no, no mana?");
        for _ in 0..10 {
            game.advance_turn().await;
        }

        Player::tap_card(player, 0, &mut game).await.expect("unable to tap, no ready?");
        // Card::tap(&player.lock().await.cards_in_play[0], &mut game, player).await;
        println!("{}", player.lock().await.render(30, 10, 30).await);
        game.play_card(player, 0, Some(posion_target)).await.expect("oh no, no mana?");

        for _ in 0..18 {
            game.advance_turn().await;
        }
        game.play_card(player2, 0, None).await.expect("oh no");
        Player::tap_card(player2, 0, &mut game).await.expect("unable to tap, no ready?");
        let target_card = {
            let card = &player.lock().await.cards_in_play[1];
            Arc::clone(card)
        };
        game.play_card(player2, 0, Some(EffectTarget::Card(target_card))).await.expect("oh no");

        for _ in 0..7 {
            game.advance_turn().await;
        }
    }
    
    
    /**
Player 1's turn: ------
┌────────────────────────────┐ H   P  
│          Player 1          │ H   P  
├────────────────────────────┤ H   P  
│ Alive: true                │ H   P  
├────────────────────────────┤ H   P  
│ Action Points: 5           │ H   P  
│ Health: 100                │ H   P  
│ Mana:                      │ H   P  
│                            │ H   P  
└────────────────────────────┘ H   P  

Player 1 draws a card.
Player 2's turn: ------
┌────────────────────────────┐ H   P  
│          Player 2          │ H   P  
├────────────────────────────┤ H   P  
│ Alive: true                │ H   P  
├────────────────────────────┤ H   P  
│ Health: 100                │ H   P  
│ Action Points: 5           │ H   P  
│ Mana:                      │ H   P  
│                            │ H   P  
└────────────────────────────┘ H   P  

Player 2 draws a card.
Player 1's turn: ------
┌────────────────────────────┐ H  ┌────────────────────────────┐ P  
│          Player 1          │ H  │           Swamp            │ P  
├────────────────────────────┤ H  ├────────────────────────────┤ P  
│ Alive: true                │ H  │                   0/0      │ P  
├────────────────────────────┤ H  ├────────────────────────────┤ P  
│ Action Points: 5           │ H  │ TAP: Adds 1 Swamp mana to  │ P  
│ Health: 100                │ H  │ your pool                  │ P  
│ Mana:                      │ H  │                            │ P  
│                            │ H  └────────────────────────────┘ P  
└────────────────────────────┘ H                                 P  

Player 1 draws a card.
Player Player 1 paid  mana for Swamp
Player 1 targeted card 
 ┌────────────────────────────┐
 │           Swamp            │
 ├────────────────────────────┤
 │                   0/0      │
 ├────────────────────────────┤
 │ TAP: Adds 1 Swamp mana to  │
 │ your pool                  │
 │                            │
 └────────────────────────────┘
 at None
actions: []
Player 2's turn: ------
┌────────────────────────────┐ H  ┌────────────────────────────┐ P  
│          Player 2          │ H  │           Swamp            │ P  
├────────────────────────────┤ H  ├────────────────────────────┤ P  
│ Alive: true                │ H  │                   0/0      │ P  
├────────────────────────────┤ H  ├────────────────────────────┤ P  
│ Health: 100                │ H  │ TAP: Adds 1 Swamp mana to  │ P  
│ Action Points: 5           │ H  │ your pool                  │ P  
│ Mana:                      │ H  │                            │ P  
│                            │ H  └────────────────────────────┘ P  
└────────────────────────────┘ H                                 P  

Player 2 draws a card.
Player 1's turn: ------
┌────────────────────────────┐ H  ┌────────────────────────────┐ P  ┌────────────────────────────┐
│          Player 1          │ H  │           Poison           │ P  │           Swamp            │
├────────────────────────────┤ H  ├────────────────────────────┤ P  ├────────────────────────────┤
│ Alive: true                │ H  │ {B}                  2/0   │ P  │                   0/0      │
├────────────────────────────┤ H  ├────────────────────────────┤ P  ├────────────────────────────┤
│ Health: 100                │ H  │ Applies 2 damage for the   │ P  │ TAP: Adds 1 Swamp mana to  │
│ Action Points: 5           │ H  │ next 3 turns after 1 turn. │ P  │ your pool                  │
│ Mana:                      │ H  │                            │ P  │                            │
│                            │ H  └────────────────────────────┘ P  └────────────────────────────┘
└────────────────────────────┘ H                                 P                                

Player 1 draws a card.
Swamp was tapped
┌────────────────────────────┐ H  ┌────────────────────────────┐ P  ┌────────────────────────────┐
│          Player 1          │ H  │           Poison           │ P  │           Swamp            │
├────────────────────────────┤ H  ├────────────────────────────┤ P  ├────────────────────────────┤
│ Alive: true                │ H  │ {B}                  2/0   │ P  │                   0/0      │
├────────────────────────────┤ H  ├────────────────────────────┤ P  ├────────────────────────────┤
│ Health: 100                │ H  │ Applies 2 damage for the   │ P  │ TAP: Adds 1 Swamp mana to  │
│ Action Points: 5           │ H  │ next 3 turns after 1 turn. │ P  │ your pool                  │
│ Mana: {B}                  │ H  │                            │ P  │                            │
│                            │ H  └────────────────────────────┘ P  └────────────────────────────┘
└────────────────────────────┘ H                                 P                                

Player Player 1 paid {B} mana for Poison
Player 1 targeted card 
 ┌────────────────────────────┐
 │           Poison           │
 ├────────────────────────────┤
 │ {B}                  2/0   │
 ├────────────────────────────┤
 │ Applies 2 damage for the   │
 │ next 3 turns after 1 turn. │
 │                            │
 └────────────────────────────┘
 at Some(Player(Mutex { data: Player { name: "Player 2", is_alive: true, cards_in_hand: <2 cards> } }))
actions: []
Player 2's turn: ------
┌────────────────────────────┐ H  ┌────────────────────────────┐  ┌────────────────────────────┐ P  
│          Player 2          │ H  │           Swamp            │  │          Destroy           │ P  
├────────────────────────────┤ H  ├────────────────────────────┤  ├────────────────────────────┤ P  
│ Alive: true                │ H  │                   0/0      │  │ {U}                  1/0   │ P  
├────────────────────────────┤ H  ├────────────────────────────┤  ├────────────────────────────┤ P  
│ Health: 100                │ H  │ TAP: Adds 1 Swamp mana to  │  │ Destroy target card        │ P  
│ Action Points: 5           │ H  │ your pool                  │  │                            │ P  
│ Mana:                      │ H  │                            │  │                            │ P  
│                            │ H  └────────────────────────────┘  └────────────────────────────┘ P  
└────────────────────────────┘ H                                                                 P  

Player 2 draws a card.
Player 1's turn: ------
┌────────────────────────────┐ H   P  ┌────────────────────────────┐  ┌────────────────────────────┐
│          Player 1          │ H   P  │           Swamp            │  │           Poison           │
├────────────────────────────┤ H   P  ├────────────────────────────┤  ├────────────────────────────┤
│ Alive: true                │ H   P  │                   0/0      │  │ {B}                  2/0   │
├────────────────────────────┤ H   P  ├────────────────────────────┤  ├────────────────────────────┤
│ Health: 100                │ H   P  │ TAP: Adds 1 Swamp mana to  │  │ Applies 2 damage for the   │
│ Action Points: 5           │ H   P  │ your pool                  │  │ next 3 turns after 1 turn. │
│ Mana:                      │ H   P  │                            │  │                            │
│                            │ H   P  └────────────────────────────┘  └────────────────────────────┘
└────────────────────────────┘ H   P                                                                

Player 1 draws a card.
Player 2's turn: ------
┌────────────────────────────┐ H  ┌────────────────────────────┐  ┌────────────────────────────┐ P  
│          Player 2          │ H  │           Swamp            │  │          Destroy           │ P  
├────────────────────────────┤ H  ├────────────────────────────┤  ├────────────────────────────┤ P  
│ Alive: true                │ H  │                   0/0      │  │ {U}                  1/0   │ P  
├────────────────────────────┤ H  ├────────────────────────────┤  ├────────────────────────────┤ P  
│ Action Points: 5           │ H  │ TAP: Adds 1 Swamp mana to  │  │ Destroy target card        │ P  
│ Health: 100                │ H  │ your pool                  │  │                            │ P  
│ Mana:                      │ H  │                            │  │                            │ P  
│                            │ H  └────────────────────────────┘  └────────────────────────────┘ P  
└────────────────────────────┘ H                                                                 P  

Player 2 draws a card.
Player Player 2 paid  mana for Swamp
Player 2 targeted card 
 ┌────────────────────────────┐
 │           Swamp            │
 ├────────────────────────────┤
 │                   0/0      │
 ├────────────────────────────┤
 │ TAP: Adds 1 Swamp mana to  │
 │ your pool                  │
 │                            │
 └────────────────────────────┘
 at None
actions: []
Swamp was tapped
Player Player 2 paid {U} mana for Destroy
Player 2 targeted card 
 ┌────────────────────────────┐
 │          Destroy           │
 ├────────────────────────────┤
 │ {U}                  1/0   │
 ├────────────────────────────┤
 │ Destroy target card        │
 │                            │
 │                            │
 └────────────────────────────┘
 at Some(Card(Mutex { data: Card { name: "Poison", description: "Applies 2 damage for the next 3 turns after 1 turn.", card_type: Artifact, current_phase: Charging(1), target: Some(Player(Mutex { data: <locked> })), attached_cards: [], tapped: false, stats: StatManager { stats: [Stat { stat_type: Damage, intensity: 2 }] }, triggers: [CardActionTrigger { trigger_type: PhaseBased([Upkeep], Owner), action: CardDamageAction { target: Target } }], cost: [Black], owner: Some(Mutex { data: Player { name: "Player 1", is_alive: true, cards_in_hand: <0 cards> } }) } }))
actions: [CardActionWrapper { action: DestroyCardAction }]
Player 1's turn: ------
┌────────────────────────────┐ H   P  ┌────────────────────────────┐
│          Player 1          │ H   P  │           Swamp            │
├────────────────────────────┤ H   P  ├────────────────────────────┤
│ Alive: true                │ H   P  │                   0/0      │
├────────────────────────────┤ H   P  ├────────────────────────────┤
│ Health: 100                │ H   P  │ TAP: Adds 1 Swamp mana to  │
│ Action Points: 5           │ H   P  │ your pool                  │
│ Mana:                      │ H   P  │                            │
│                            │ H   P  └────────────────────────────┘
└────────────────────────────┘ H   P                                

Player 1 draws a card.
     */
Leave a Comment