Erwan
- Momir AI tweaks - More cards in shop, boosters are cheaper, each card has between 1 and 4 occurrences
This commit is contained in:
@@ -12,6 +12,8 @@
|
|||||||
#define STAGE_SHOP_MENU 3
|
#define STAGE_SHOP_MENU 3
|
||||||
#define STAGE_SHOP_SHOP 4
|
#define STAGE_SHOP_SHOP 4
|
||||||
|
|
||||||
|
#define SHOP_BOOSTERS 3
|
||||||
|
|
||||||
class GameStateShop: public GameState, public JGuiListener
|
class GameStateShop: public GameState, public JGuiListener
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -26,7 +28,8 @@ class GameStateShop: public GameState, public JGuiListener
|
|||||||
SimpleMenu * menu;
|
SimpleMenu * menu;
|
||||||
int mStage;
|
int mStage;
|
||||||
char starterBuffer[128], boosterBuffer[128];
|
char starterBuffer[128], boosterBuffer[128];
|
||||||
int setIds[2];
|
char setNames[SHOP_BOOSTERS][128];
|
||||||
|
int setIds[SHOP_BOOSTERS];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameStateShop(GameApp* parent);
|
GameStateShop(GameApp* parent);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
MTGAbility * AIMomirPlayer::momirAbility = NULL;
|
MTGAbility * AIMomirPlayer::momirAbility = NULL;
|
||||||
|
|
||||||
AIMomirPlayer::AIMomirPlayer(MTGPlayerCards * _deck, char * file, char * avatarFile): AIPlayerBaka(_deck,file, avatarFile){
|
AIMomirPlayer::AIMomirPlayer(MTGPlayerCards * _deck, char * file, char * avatarFile): AIPlayerBaka(_deck,file, avatarFile){
|
||||||
// TODO count min and max number of mana (should probably be part of the gameobserver so that human players don't make mistakes)
|
|
||||||
momirAbility = NULL;
|
momirAbility = NULL;
|
||||||
agressivity = 100;
|
agressivity = 100;
|
||||||
}
|
}
|
||||||
@@ -35,29 +34,32 @@ MTGAbility * AIMomirPlayer::getMomirAbility(){
|
|||||||
|
|
||||||
int AIMomirPlayer::momir(){
|
int AIMomirPlayer::momir(){
|
||||||
if (!game->hand->nb_cards) return 0; //nothing to discard :/
|
if (!game->hand->nb_cards) return 0; //nothing to discard :/
|
||||||
|
int result = 0;
|
||||||
|
int opponentCreatures = getCreaturesInfo(opponent(), INFO_NBCREATURES);
|
||||||
|
int myCreatures = getCreaturesInfo(this, INFO_NBCREATURES );
|
||||||
getPotentialMana();
|
getPotentialMana();
|
||||||
int converted = potentialMana->getConvertedCost();
|
int converted = potentialMana->getConvertedCost();
|
||||||
int efficiency = 100;
|
int efficiency = 100;
|
||||||
int chance = 1 + (rand() % 100);
|
int chance = 1 + (rand() % 100);
|
||||||
if (converted == 5) efficiency = 5 ; //Strategy: skip 5 drop
|
if (converted == 5 && myCreatures > opponentCreatures && game->hand->nb_cards<4) efficiency = 5 ; //Strategy: skip 5 drop
|
||||||
if (converted == 7) efficiency = 50; //Strategy: 7 drops have bad upkeep costs and the AI doesn't handle those right now...
|
if (converted == 7 && myCreatures > opponentCreatures && game->hand->nb_cards<2) efficiency = 50; //Strategy: 7 drops have bad upkeep costs and the AI doesn't handle those right now...
|
||||||
if (converted > 8 ) converted = 8;
|
if (converted > 8 ) converted = 8;
|
||||||
if (converted == 8) efficiency = 100 - game->inPlay->nb_cards;
|
if (converted == 8) efficiency = 100 - (myCreatures-opponentCreatures);
|
||||||
|
|
||||||
if (efficiency >= chance){
|
if (efficiency >= chance){
|
||||||
int _cost[] = {Constants::MTG_COLOR_ARTIFACT,converted};
|
int _cost[] = {Constants::MTG_COLOR_ARTIFACT,converted};
|
||||||
ManaCost * cost = NEW ManaCost(_cost);
|
ManaCost * cost = NEW ManaCost(_cost);
|
||||||
tapLandsForMana(potentialMana,cost);
|
|
||||||
delete cost;
|
|
||||||
MTGAbility * ability = getMomirAbility();
|
MTGAbility * ability = getMomirAbility();
|
||||||
MTGCardInstance * card = game->hand->cards[0];
|
MTGCardInstance * card = game->hand->cards[0];
|
||||||
if (ability->isReactingToClick(card,cost)){
|
if (ability->isReactingToClick(card,cost)){
|
||||||
|
tapLandsForMana(potentialMana,cost);
|
||||||
AIAction * a = NEW AIAction(ability,card);
|
AIAction * a = NEW AIAction(ability,card);
|
||||||
clickstream.push(a);
|
clickstream.push(a);
|
||||||
return 1;
|
result = 1;
|
||||||
}
|
}
|
||||||
|
delete cost;
|
||||||
}
|
}
|
||||||
return 0;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AIMomirPlayer::computeActions(){
|
int AIMomirPlayer::computeActions(){
|
||||||
|
|||||||
@@ -49,22 +49,25 @@ void GameStateShop::Start()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbsets){
|
if (nbsets){
|
||||||
setIds[0] = sets[(rand() % nbsets)];
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
setIds[1] = sets[(rand() % nbsets)];
|
setIds[i] = sets[(rand() % nbsets)];
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
setIds[0] = (rand() % MtgSets::SetsList->nb_items);
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
setIds[1] = (rand() % MtgSets::SetsList->nb_items);
|
setIds[i] = (rand() % MtgSets::SetsList->nb_items);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
JQuad * mBackThumb = GameApp::CommonRes->GetQuad("back_thumb");
|
JQuad * mBackThumb = GameApp::CommonRes->GetQuad("back_thumb");
|
||||||
|
|
||||||
shop = NULL;
|
shop = NULL;
|
||||||
|
|
||||||
shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
|
shop = NEW ShopItems(10, this, itemFont, 10, 0, mParent->collection, setIds);
|
||||||
sprintf(starterBuffer, "%s Booster (15 cards)",MtgSets::SetsList->values[setIds[0]].c_str());
|
for (int i = 0; i < SHOP_BOOSTERS; i++){
|
||||||
sprintf(boosterBuffer, "%s Booster (15 cards)",MtgSets::SetsList->values[setIds[1]].c_str());
|
sprintf(setNames[i], "%s Booster (15 cards)",MtgSets::SetsList->values[setIds[i]].c_str());
|
||||||
shop->Add(starterBuffer,mBack,mBackThumb, 1900);
|
shop->Add(setNames[i],mBack,mBackThumb, 1200);
|
||||||
shop->Add(boosterBuffer,mBack,mBackThumb, 1900);
|
}
|
||||||
for (int i = 0; i < 5; i++){
|
|
||||||
|
for (int i = 0; i < 8; i++){
|
||||||
shop->Add(mParent->collection->randomCardId());
|
shop->Add(mParent->collection->randomCardId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/ShopItem.h"
|
#include "../include/ShopItem.h"
|
||||||
|
#include "../include/GameStateShop.h"
|
||||||
#include "../include/CardGui.h"
|
#include "../include/CardGui.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ ShopItem::ShopItem(int id, JLBFont *font, int _cardid, int x, int y, bool hasFoc
|
|||||||
Entering();
|
Entering();
|
||||||
|
|
||||||
card = collection->getCardById(_cardid);
|
card = collection->getCardById(_cardid);
|
||||||
quantity = 1;
|
quantity = 1 + (rand() % 4);
|
||||||
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
|
if (card->getRarity() == Constants::RARITY_L) quantity = 50;
|
||||||
quad = NULL;
|
quad = NULL;
|
||||||
thumb = NULL;
|
thumb = NULL;
|
||||||
@@ -43,15 +44,41 @@ const char * ShopItem::getText(){
|
|||||||
|
|
||||||
|
|
||||||
void ShopItem::Render(){
|
void ShopItem::Render(){
|
||||||
|
if (mHasFocus){
|
||||||
|
mFont->SetColor(ARGB(255,255,255,0));
|
||||||
|
}else{
|
||||||
|
mFont->SetColor(ARGB(255,255,255,255));
|
||||||
|
}
|
||||||
|
if (!quantity){
|
||||||
|
mFont->SetColor(ARGB(255,128,128,128));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
JRenderer * renderer = JRenderer::GetInstance();
|
JRenderer * renderer = JRenderer::GetInstance();
|
||||||
renderer->FillRect(mX-5, mY-5,230,35, ARGB(128,0,0,0));
|
float x0 = mX;
|
||||||
|
float y0 = mY - (mScale > 1 ? 4 : 0);
|
||||||
|
if (GetId()%2){
|
||||||
|
float xs[] = {mX, mX, mX+230,mX+230};
|
||||||
|
float ys[] = {mY-5+17,mY-5+19,mY-5+35,mY-5} ;
|
||||||
|
|
||||||
|
renderer->FillPolygon(xs,ys,4,ARGB(200,0,0,0));
|
||||||
|
x0 = mX + 230 -30;
|
||||||
|
mFont->DrawString(mText.c_str(), x0, mY + 8,JGETEXT_RIGHT);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
float xs[] = {mX-5, mX-5, mX-5+230,mX-5+230,};
|
||||||
|
float ys[] = {mY-5,mY-5+35,mY-5+17,mY-5+19} ;
|
||||||
|
renderer->FillPolygon(xs,ys,4,ARGB(128,0,0,0));
|
||||||
|
mFont->DrawString(mText.c_str(), mX + 30, mY + 8);
|
||||||
|
}
|
||||||
|
//renderer->FillRect(mX-5, mY-5,230,35, );
|
||||||
if (card){
|
if (card){
|
||||||
thumb = card->getThumb();
|
thumb = card->getThumb();
|
||||||
mText= card->name;
|
mText= card->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thumb){
|
if (thumb){
|
||||||
renderer->RenderQuad(thumb,mX,mY - (mScale > 1 ? 4 : 0),0,mScale * 0.45,mScale * 0.45);
|
renderer->RenderQuad(thumb,x0,y0,0,mScale * 0.45,mScale * 0.45);
|
||||||
}else{
|
}else{
|
||||||
//NOTHING
|
//NOTHING
|
||||||
}
|
}
|
||||||
@@ -64,14 +91,7 @@ void ShopItem::Render(){
|
|||||||
}else{
|
}else{
|
||||||
if (card) CardGui::alternateRender(card,NULL,mX + SCREEN_WIDTH/2 + 100 + 20,133,0, 0.9f);
|
if (card) CardGui::alternateRender(card,NULL,mX + SCREEN_WIDTH/2 + 100 + 20,133,0, 0.9f);
|
||||||
}
|
}
|
||||||
mFont->SetColor(ARGB(255,255,255,0));
|
|
||||||
}else{
|
|
||||||
mFont->SetColor(ARGB(255,255,255,255));
|
|
||||||
}
|
}
|
||||||
if (!quantity){
|
|
||||||
mFont->SetColor(ARGB(255,128,128,128));
|
|
||||||
}
|
|
||||||
mFont->DrawString(mText.c_str(), mX + 30, mY + 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -122,7 +142,7 @@ ShopItems::ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y
|
|||||||
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",_collection);
|
pricelist = NEW PriceList(RESPATH"/settings/prices.dat",_collection);
|
||||||
playerdata = NEW PlayerData(_collection);
|
playerdata = NEW PlayerData(_collection);
|
||||||
display = NULL;
|
display = NULL;
|
||||||
for (int i=0; i < 2; i++){
|
for (int i=0; i < SHOP_BOOSTERS; i++){
|
||||||
setIds[i] = _setIds[i];
|
setIds[i] = _setIds[i];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -134,12 +154,12 @@ void ShopItems::Add(int cardid){
|
|||||||
int price = pricelist->getPrice(cardid);
|
int price = pricelist->getPrice(cardid);
|
||||||
price = price + price * (rnd -10)/100;
|
price = price + price * (rnd -10)/100;
|
||||||
JGuiController::Add(NEW ShopItem(mCount, mFont, cardid, mX + 10, mY + 10 + mHeight, (mCount == 0),collection, price));
|
JGuiController::Add(NEW ShopItem(mCount, mFont, cardid, mX + 10, mY + 10 + mHeight, (mCount == 0),collection, price));
|
||||||
mHeight += 38;
|
mHeight += 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){
|
void ShopItems::Add(char * text, JQuad * quad,JQuad * thumb, int price){
|
||||||
JGuiController::Add(NEW ShopItem(mCount, mFont, text, quad, thumb, mX + 10, mY + 10 + mHeight, (mCount == 0), price));
|
JGuiController::Add(NEW ShopItem(mCount, mFont, text, quad, thumb, mX + 10, mY + 10 + mHeight, (mCount == 0), price));
|
||||||
mHeight += 38;
|
mHeight += 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShopItems::Update(float dt){
|
void ShopItems::Update(float dt){
|
||||||
|
|||||||
Reference in New Issue
Block a user