<commit_before>// Copyright (c) 2019 <NAME>, <NAME>, <NAME>

// We are making my contributions/submissions to this project solely in our
// personal capacity and are not conveying any rights to any intellectual
// property of any third parties.

#include <Utils/TestUtils.hpp>
#include "gtest/gtest.h"

#include <Rosetta/Games/Game.hpp>
#include <Rosetta/Games/GameConfig.hpp>
#include <Rosetta/Games/GameManager.hpp>
#include <Rosetta/Policies/BasicPolicy.hpp>
#include <Rosetta/Tasks/PlayerTasks/ChooseTask.hpp>

using namespace RosettaStone;
using namespace PlayerTasks;

struct MulliganTestPolicy : BasicPolicy
{
    TaskMeta RequireMulligan(Player&) override
    {
        return TaskMeta(TaskMetaTrait(TaskID::MULLIGAN), std::vector<size_t>());
    }
};

TEST(Game, Mulligan)
{
    GameConfig config;
    config.player1Class = CardClass::WARRIOR;
    config.player2Class = CardClass::ROGUE;
    config.startPlayer = PlayerType::PLAYER1;
    config.doFillDecks = true;
    config.skipMulligan = false;
    config.autoRun = false;

    Game game(config);
    game.StartGame();

    auto& curPlayer = game.GetCurrentPlayer();
    auto& opPlayer = game.GetOpponentPlayer();

    MulliganTestPolicy policy;
    curPlayer.policy = &policy;
    opPlayer.policy = &policy;

    game.nextStep = Step::BEGIN_MULLIGAN;
    GameManager::ProcessNextStep(game, game.nextStep);
}<commit_msg>test: Add unit test for checking game over<commit_after>// Copyright (c) 2019 <NAME>, <NAME>, <NAME>

// We are making my contributions/submissions to this project solely in our
// personal capacity and are not conveying any rights to any intellectual
// property of any third parties.

#include <Utils/TestUtils.hpp>
#include "gtest/gtest.h"

#include <Rosetta/Actions/Draw.hpp>
#include <Rosetta/Cards/Cards.hpp>
#include <Rosetta/Games/Game.hpp>
#include <Rosetta/Games/GameConfig.hpp>
#include <Rosetta/Games/GameManager.hpp>
#include <Rosetta/Policies/BasicPolicy.hpp>
#include <Rosetta/Tasks/PlayerTasks/AttackTask.hpp>
#include <Rosetta/Tasks/PlayerTasks/PlayCardTask.hpp>

using namespace RosettaStone;
using namespace PlayerTasks;

struct MulliganTestPolicy : BasicPolicy
{
    TaskMeta RequireMulligan(Player&) override
    {
        return TaskMeta(TaskMetaTrait(TaskID::MULLIGAN), std::vector<size_t>());
    }
};

TEST(Game, Mulligan)
{
    GameConfig config;
    config.player1Class = CardClass::WARRIOR;
    config.player2Class = CardClass::ROGUE;
    config.startPlayer = PlayerType::PLAYER1;
    config.doFillDecks = true;
    config.skipMulligan = false;
    config.autoRun = false;

    Game game(config);
    game.StartGame();

    auto& curPlayer = game.GetCurrentPlayer();
    auto& opPlayer = game.GetOpponentPlayer();

    MulliganTestPolicy policy;
    curPlayer.policy = &policy;
    opPlayer.policy = &policy;

    game.nextStep = Step::BEGIN_MULLIGAN;
    GameManager::ProcessNextStep(game, game.nextStep);
}

TEST(Game, GameOver)
{
    GameConfig config;
    config.player1Class = CardClass::WARRIOR;
    config.player2Class = CardClass::ROGUE;
    config.startPlayer = PlayerType::PLAYER1;
    config.doFillDecks = true;
    config.autoRun = false;

    Game game(config);
    game.StartGame();
    game.ProcessUntil(Step::MAIN_START);

    Player& curPlayer = game.GetCurrentPlayer();
    Player& opPlayer = game.GetOpponentPlayer();
    curPlayer.SetTotalMana(10);
    curPlayer.SetUsedMana(0);
    opPlayer.SetTotalMana(10);
    opPlayer.SetUsedMana(0);
    opPlayer.GetHero()->SetDamage(29);

    const auto card1 = Generic::DrawCard(
        curPlayer, Cards::GetInstance().FindCardByName("Wolfrider"));

    Task::Run(curPlayer, PlayCardTask::Minion(curPlayer, card1));
    game.Process(AttackTask(card1, opPlayer.GetHero()));

    EXPECT_EQ(game.state, State::COMPLETE);
    EXPECT_EQ(curPlayer.playState, PlayState::WON);
    EXPECT_EQ(opPlayer.playState, PlayState::LOST);
}
{'fraction_non_alphanumeric': 0.12118100128369705, 'fraction_numerical': 0.007188703465982028, 'mean_word_length': 4.464235624123422, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1865476', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1253, 'n_words': 255}