added current AI deck name to "start" menu while dueling
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
class AIMomirPlayer:public AIPlayerBaka{
|
||||
public:
|
||||
AIMomirPlayer(MTGPlayerCards * deck, string file, string fileSmall, string avatarFile);
|
||||
AIMomirPlayer(MTGDeck * deck, string file, string fileSmall, string avatarFile);
|
||||
int getEfficiency(AIAction * action);
|
||||
int momir();
|
||||
int computeActions();
|
||||
|
||||
@@ -71,7 +71,7 @@ class AIPlayer: public Player{
|
||||
void Render();
|
||||
AIStats * stats;
|
||||
ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
|
||||
AIPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
||||
AIPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
virtual ~AIPlayer();
|
||||
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
|
||||
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget =NULL);
|
||||
@@ -94,7 +94,7 @@ class AIPlayerBaka: public AIPlayer{
|
||||
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
|
||||
public:
|
||||
int deckId;
|
||||
AIPlayerBaka(MTGPlayerCards * deck, string deckFile, string deckfileSmall, string avatarFile);
|
||||
AIPlayerBaka(MTGDeck * deck, string deckFile, string deckfileSmall, string avatarFile);
|
||||
virtual int Act(float dt);
|
||||
void initTimer();
|
||||
virtual int computeActions();
|
||||
|
||||
@@ -374,6 +374,8 @@ public:
|
||||
int resolve(){
|
||||
vector<int>::size_type sz = abilities.size();
|
||||
for (unsigned int i = 0; i < sz; i++){
|
||||
if (abilities[i] == NULL)
|
||||
continue;
|
||||
Targetable * backup = abilities[i]->target;
|
||||
if (target && target!= source && abilities[i]->target == abilities[i]->source) abilities[i]->target = target;
|
||||
abilities[i]->resolve();
|
||||
|
||||
@@ -60,7 +60,8 @@ class GameStateDuel: public GameState, public JGuiListener
|
||||
MENUITEM_RANDOM_PLAYER = -11,
|
||||
MENUITEM_RANDOM_AI = -12,
|
||||
MENUITEM_MAIN_MENU = -13,
|
||||
MENUITEM_EVIL_TWIN = -14
|
||||
MENUITEM_EVIL_TWIN = -14,
|
||||
MENUITEM_MULLIGAN = -15
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "Damage.h"
|
||||
#include "Targetable.h"
|
||||
|
||||
class MTGDeck;
|
||||
class MTGPlayerCards;
|
||||
class MTGInPlay;
|
||||
class ManaPool;
|
||||
@@ -45,7 +46,7 @@ class Player: public Damageable{
|
||||
int poisoned();
|
||||
int damaged();
|
||||
int prevented();
|
||||
Player(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
||||
Player(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
virtual ~Player();
|
||||
void unTapPhase();
|
||||
MTGInPlay * inPlay();
|
||||
@@ -58,6 +59,7 @@ class Player: public Damageable{
|
||||
JQuad * getIcon();
|
||||
string deckFile;
|
||||
string deckFileSmall;
|
||||
string deckName;
|
||||
|
||||
virtual int receiveEvent(WEvent * event){return 0;};
|
||||
virtual void Render(){};
|
||||
@@ -66,7 +68,7 @@ class Player: public Damageable{
|
||||
|
||||
class HumanPlayer: public Player{
|
||||
public:
|
||||
HumanPlayer(MTGPlayerCards * deck, string deckFile, string deckFileSmall);
|
||||
HumanPlayer(MTGDeck * deck, string deckFile, string deckFileSmall);
|
||||
HumanPlayer(string deckFile);
|
||||
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
MTGAbility * AIMomirPlayer::momirAbility = NULL;
|
||||
|
||||
AIMomirPlayer::AIMomirPlayer(MTGPlayerCards * deck, string file, string fileSmall, string avatarFile) : AIPlayerBaka(deck, file, fileSmall, avatarFile) {
|
||||
AIMomirPlayer::AIMomirPlayer(MTGDeck * deck, string file, string fileSmall, string avatarFile) : AIPlayerBaka(deck, file, fileSmall, avatarFile) {
|
||||
momirAbility = NULL;
|
||||
agressivity = 100;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ int AIAction::Act(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
AIPlayer::AIPlayer(MTGPlayerCards * deck, string file, string fileSmall) : Player(deck, file, fileSmall) {
|
||||
AIPlayer::AIPlayer(MTGDeck * deck, string file, string fileSmall) : Player(deck, file, fileSmall) {
|
||||
nextCardToPlay = NULL;
|
||||
stats = NULL;
|
||||
agressivity = 50;
|
||||
@@ -605,10 +605,11 @@ AIPlayer * AIPlayerFactory::createAIPlayer(MTGAllCards * collection, Player * op
|
||||
}
|
||||
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, collection);
|
||||
MTGPlayerCards * deck = NEW MTGPlayerCards(tempDeck);
|
||||
//MTGPlayerCards * deck = NEW MTGPlayerCards(tempDeck);
|
||||
AIPlayerBaka * baka = NEW AIPlayerBaka(tempDeck,deckFile, deckFileSmall, avatarFile);
|
||||
baka->deckId = deckid;
|
||||
|
||||
delete tempDeck;
|
||||
AIPlayerBaka * baka = NEW AIPlayerBaka(deck,deckFile, deckFileSmall, avatarFile);
|
||||
baka->deckId = deckid;
|
||||
return baka;
|
||||
}
|
||||
|
||||
@@ -664,7 +665,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
return nextCardToPlay;
|
||||
}
|
||||
|
||||
AIPlayerBaka::AIPlayerBaka(MTGPlayerCards * deck, string file, string fileSmall, string avatarFile) : AIPlayer(deck, file, fileSmall) {
|
||||
AIPlayerBaka::AIPlayerBaka(MTGDeck * deck, string file, string fileSmall, string avatarFile) : AIPlayer(deck, file, fileSmall) {
|
||||
mAvatarTex = resources.RetrieveTexture(avatarFile,RETRIEVE_LOCK,TEXTURE_SUB_AVATAR);
|
||||
|
||||
if(!mAvatarTex){
|
||||
@@ -680,6 +681,7 @@ AIPlayerBaka::AIPlayerBaka(MTGPlayerCards * deck, string file, string fileSmall,
|
||||
initTimer();
|
||||
}
|
||||
|
||||
|
||||
void AIPlayerBaka::initTimer(){
|
||||
timer = 0.1f;
|
||||
}
|
||||
|
||||
@@ -146,11 +146,12 @@ void GameStateDuel::loadPlayer(int playerId, int decknb, int isAI){
|
||||
char deckFileSmall[255];
|
||||
sprintf(deckFileSmall, "player_deck%i",decknb);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, mParent->collection);
|
||||
deck[playerId] = NEW MTGPlayerCards(tempDeck);
|
||||
mPlayers[playerId] = NEW HumanPlayer(tempDeck, deckFile, deckFileSmall);
|
||||
|
||||
deck[playerId] = mPlayers[playerId]->game;
|
||||
delete tempDeck;
|
||||
mPlayers[playerId] = NEW HumanPlayer(deck[playerId],deckFile, deckFileSmall);
|
||||
}
|
||||
else { //AI Player, chose deck
|
||||
else { //AI Player, chooses deck
|
||||
AIPlayerFactory playerCreator;
|
||||
Player * opponent = NULL;
|
||||
if (playerId == 1) opponent = mPlayers[0];
|
||||
@@ -371,7 +372,7 @@ void GameStateDuel::Update(float dt)
|
||||
}
|
||||
if (mEngine->GetButtonClick(JGE_BTN_MENU)) {
|
||||
if (!menu) {
|
||||
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, Constants::MENU_FONT, SCREEN_WIDTH/2-100, 25);
|
||||
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, Constants::MENU_FONT, SCREEN_WIDTH/2-100, 25, game->players[1]->deckName.c_str());
|
||||
int cardsinhand = game->players[0]->game->hand->nb_cards;
|
||||
|
||||
//almosthumane - mulligan
|
||||
@@ -382,11 +383,11 @@ void GameStateDuel::Update(float dt)
|
||||
&& game->players[0]->game->exile->nb_cards == 0) //1st Play Check
|
||||
//IF there was no play at the moment automatically mulligan
|
||||
{
|
||||
menu->Add(14,"Mulligan");
|
||||
menu->Add( MENUITEM_MULLIGAN, "Mulligan");
|
||||
}
|
||||
//END almosthumane - mulligan
|
||||
menu->Add(12, "Back to main menu");
|
||||
menu->Add(13, "Cancel");
|
||||
menu->Add(MENUITEM_MAIN_MENU, "Back to main menu");
|
||||
menu->Add(MENUITEM_CANCEL, "Cancel");
|
||||
}
|
||||
mGamePhase = DUEL_STATE_MENU;
|
||||
}
|
||||
@@ -577,15 +578,15 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId) {
|
||||
switch (controlId)
|
||||
{
|
||||
|
||||
case 12:
|
||||
case MENUITEM_MAIN_MENU:
|
||||
menu->Close();
|
||||
mGamePhase = DUEL_STATE_BACK_TO_MAIN_MENU;
|
||||
break;
|
||||
case 13:
|
||||
case MENUITEM_CANCEL:
|
||||
menu->Close();
|
||||
mGamePhase = DUEL_STATE_CANCEL;
|
||||
break;
|
||||
case 14:
|
||||
case MENUITEM_MULLIGAN:
|
||||
//almosthumane - mulligan
|
||||
{
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
#include "../include/ManaCost.h"
|
||||
|
||||
|
||||
Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageable(20){
|
||||
|
||||
|
||||
Player::Player(MTGDeck * deck, string file, string fileSmall) : Damageable(20){
|
||||
deckFile = file;
|
||||
deckFileSmall = fileSmall;
|
||||
game = deck;
|
||||
game->setOwner(this);
|
||||
manaPool = NEW ManaPool(this);
|
||||
canPutLandsIntoPlay = 1;
|
||||
nomaxhandsize = 0;
|
||||
@@ -28,6 +28,12 @@ Player::Player(MTGPlayerCards * deck, string file, string fileSmall) : Damageabl
|
||||
mAvatarTex = NULL;
|
||||
type_as_damageable = DAMAGEABLE_PLAYER;
|
||||
playMode = MODE_HUMAN;
|
||||
if ( deck != NULL )
|
||||
{
|
||||
game = NEW MTGPlayerCards( deck );
|
||||
game->setOwner(this);
|
||||
deckName = deck->meta_name;
|
||||
}
|
||||
}
|
||||
|
||||
/*Method to call at the end of a game, before all objects involved in the game are destroyed */
|
||||
@@ -37,6 +43,7 @@ void Player::End(){
|
||||
|
||||
Player::~Player(){
|
||||
SAFE_DELETE(manaPool);
|
||||
SAFE_DELETE(game);
|
||||
resources.Release(mAvatarTex);
|
||||
mAvatar = NULL;
|
||||
mAvatarTex = NULL;
|
||||
@@ -83,13 +90,13 @@ Player * Player::opponent(){
|
||||
return this == game->players[0] ? game->players[1] : game->players[0];
|
||||
}
|
||||
|
||||
HumanPlayer::HumanPlayer(MTGPlayerCards * deck, string file, string fileSmall) : Player(deck, file, fileSmall) {
|
||||
|
||||
HumanPlayer::HumanPlayer(MTGDeck * deck, string file, string fileSmall) : Player(deck, file, fileSmall) {
|
||||
loadAvatar("avatar.jpg");
|
||||
playMode = MODE_HUMAN;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ManaPool * Player::getManaPool(){
|
||||
return manaPool;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ void Rules::addExtraRules(){
|
||||
Player * Rules::loadPlayerMomir(int isAI){
|
||||
string deckFileSmall = "momir";
|
||||
char empty[] = "";
|
||||
|
||||
|
||||
MTGDeck * tempDeck = NEW MTGDeck(GameApp::collection); //Autogenerate a momir deck. Leave the "momir.txt" bits below for stats.
|
||||
tempDeck->addRandomCards(12, 0,0,Constants::RARITY_L,"Forest");
|
||||
tempDeck->addRandomCards(12, 0,0,Constants::RARITY_L,"Plains");
|
||||
@@ -172,13 +172,14 @@ Player * Rules::loadPlayerMomir(int isAI){
|
||||
tempDeck->addRandomCards(12, 0,0,Constants::RARITY_L,"Mountain");
|
||||
tempDeck->addRandomCards(12, 0,0,Constants::RARITY_L,"Island");
|
||||
|
||||
MTGPlayerCards * deck = NEW MTGPlayerCards( tempDeck);
|
||||
delete tempDeck;
|
||||
Player *player = NULL;
|
||||
if (!isAI) // Human Player
|
||||
return NEW HumanPlayer(deck, options.profileFile("momir.txt","",true).c_str(), deckFileSmall);
|
||||
player = NEW HumanPlayer(tempDeck, options.profileFile("momir.txt","",true).c_str(), deckFileSmall);
|
||||
else
|
||||
return NEW AIMomirPlayer(deck, options.profileFile("momir.txt","",true).c_str(), deckFileSmall, empty);
|
||||
player = NEW AIMomirPlayer(tempDeck, options.profileFile("momir.txt","",true).c_str(), deckFileSmall, empty);
|
||||
|
||||
delete tempDeck;
|
||||
return player;
|
||||
}
|
||||
|
||||
Player * Rules::loadPlayerRandom(int isAI, int mode){
|
||||
@@ -206,13 +207,13 @@ Player * Rules::loadPlayerRandom(int isAI, int mode){
|
||||
string deckFile = "random";
|
||||
string deckFileSmall = "random";
|
||||
|
||||
MTGPlayerCards * deck = NEW MTGPlayerCards(tempDeck);
|
||||
delete tempDeck;
|
||||
|
||||
Player *player = NULL;
|
||||
if (!isAI) // Human Player
|
||||
return NEW HumanPlayer(deck, deckFile, deckFileSmall);
|
||||
player = NEW HumanPlayer(tempDeck, deckFile, deckFileSmall);
|
||||
else
|
||||
return NEW AIPlayerBaka(deck,deckFile, deckFileSmall, "");
|
||||
player = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, "");
|
||||
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -274,13 +274,13 @@ void StoryDuel::init(){
|
||||
sprintf(deckFile, "%s/deck.txt", folder);
|
||||
MTGDeck * tempDeck = NEW MTGDeck(deckFile, GameApp::collection);
|
||||
sprintf(deckFileSmall, "campaign_%s", mParent->folder.c_str());
|
||||
players[0] = NEW HumanPlayer(NEW MTGPlayerCards(tempDeck),deckFile,deckFileSmall);
|
||||
players[0] = NEW HumanPlayer(tempDeck, deckFile, deckFileSmall);
|
||||
SAFE_DELETE(tempDeck);
|
||||
|
||||
sprintf(deckFile,"%s/opponent_deck.txt", folder);
|
||||
tempDeck = NEW MTGDeck(deckFile, GameApp::collection);
|
||||
sprintf(deckFileSmall, "campaign_ennemy_%s_%s", mParent->folder.c_str(), pageId.c_str());
|
||||
players[1] = NEW AIPlayerBaka(NEW MTGPlayerCards(tempDeck),deckFile,deckFileSmall,"baka.jpg");
|
||||
players[1] = NEW AIPlayerBaka(tempDeck, deckFile, deckFileSmall, "baka.jpg");
|
||||
SAFE_DELETE(tempDeck);
|
||||
|
||||
string rulesFile = folder;
|
||||
|
||||
@@ -11,11 +11,15 @@
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
|
||||
TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId):AIPlayerBaka(_suite->buildDeck(playerId),"testsuite", "testsuite","baka.jpg"){
|
||||
// NULL is sent in place of a MTGDeck since there is no way to create a MTGDeck without a proper deck file.
|
||||
// TestSuiteAI will be responsible for managing its own deck state.
|
||||
TestSuiteAI::TestSuiteAI(TestSuite * _suite, int playerId):AIPlayerBaka(NULL, "testsuite", "testsuite", "baka.jpg") {
|
||||
this->game = _suite->buildDeck(playerId);
|
||||
game->setOwner( this );
|
||||
suite = _suite;
|
||||
timer = 0;
|
||||
playMode = MODE_TEST_SUITE;
|
||||
this->deckName = "Test Suite AI";
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user