Files
wagic/projects/mtg/src/GameStateOptions.cpp
T
omegablast2002@yahoo.com 473abd9814 im forced to do this commit in whole instead of parts as originally planned, and before my beta test period of the changes is complete BECAUSE there are people doing "clean up" and the MASSIVE amount of conflicts i have to resolve from it is WAY too much for me to take on after nearly 200 hours of coding this patch. i cant seem to get enough respect to have people hold off on "clean up" so this brings me to being forced to do a full commit before playtest period is done, so they can go ahead with there *super important* clean up.
ok i WAS going to write a full change log with code exsamples ect, but since im rushed you will get the short version of this log.

first bug fixes, and there were many, 
indestructible creature bug fixed
halimar execavator *embearessing youtube video" bug is fixed

token text now displays source name and tokens abilities

fixed a card view null pointer in an iterator when code used combinations of foreach and aslongas with CD.

epic struggle bug fixed, aslongas was only parsing one space to the right of the operator.

extra cost containing targetting fixed, cards can now have multiple extra cost in all mana...this includes giving a card 2 targeted sacrifices as its main cost.

angelic chorus bug fixed, the card will be soft coded now.

and many other minor bugs fixed, hard to remember all which were fixed.

now, new abilities = words
"legendarylandwalk",
"desertlandwalk",
"snowforestlandwalk",
"snowplainslandwalk",
"snowmountainlandwalk",
"snowislandlandwalk",
"snowswamplandwalk",
"snowlandwalk",
"nonbasiclandwalk",
"strong",//cant be blocked by creature with less power
"weak",//cant block creatures with more power
"phasing",

all true landwalks will now be supported.

new cost types:
morph which is coded as follows
[card]
name=Bloodstoke Howler
facedown={3}
autofacedown={6}{R}:morph
autofaceup=3/0 all(beast|mybattlefield))
text=Morph {6}{R} (You may cast this face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost.) -- When Bloodstoke Howler is turned 
face up, Beast creatures you control get +3/+0 until end of turn.
mana={5}{R}
type=Creature
subtype=Beast
power=3
toughness=4
[/card]

you will notice new auto lines autofaceup and autofacedown
these are abilities the cards will have when theyre in that state.
the cost is coded as
facedown={cost}
when a card is faced up it gains auto= lines also.
tho is played normally it will NOT gain autofaceup=lines

card restrictions:
cards can now have restrictions placed on them the restrictions are.
all previous restrictions usable in activated abilities
with the follow additions
control two or more vampires
control less creatures
control snow land
casted a spell
one of a kind
fourth turn
before battle damage
after battle
during battle

[card]
name=Blood Frenzy
target=creature[attacking;blocking]
restriction=before battle damage
auto=4/0
auto=treason
text=Cast Blood Frenzy only before the combat damage step. -- Target attacking or blocking creature gets +4/+0 until end of turn. Destroy that creature 
at the beginning of the next end step.
mana={1}{R}
type=Instant
[/card]

other cost now can have specail restrictions also:
otherrestriction=mytypemin:1 type(swamp),opponenttypemin:1 opponenttype(plains)
these are minimums required inplay of a type
it can be just you, or you and opponent or just opponent
you can also use the words "more" and "less" and * to compare the 2 players fields.

[card]
name=Cho-Arrim Legate
abilities=protection from black
other={0}
otherrestriction=mytypemin:1 type(swamp) , opponenttypemin:1 opponenttype(plains)
text=Protection from black -- If an opponent controls a Swamp and you control a Plains, you may cast Cho-Arrim Legate without paying its mana cost.
mana={2}{W}
type=Creature
subtype=Human Soldier
power=1
toughness=2
[/card]

activated ability gained a new restriction "opponentturnonly"

variables will now be recalculated during the resolve of the major abilities to produce the most current number.
{x}:draw:x <----
new number variables words:
using draw as an exsample
draw:auras <--auras on a creature

draw:type:ally <---counts the allys in your field. self explanitory

draw:thatmuch <--mostly a triggered effects number.
when you take damage draw that much

draw:lifelost
draw:oplifelost
these return the value of the life lost that turn.

new TRIGGER restricitions
sourcenottap
sourceTap
foelostthree<--card cycle uses opponent lost life
foelosttwo<--same as above
once<--this trigger will only ever trigger one time and never again.

new card discriptor words
[multicolor]
[leveler]
[enchanted]
[blackandgreen]
[blackandwhite]
[redandblue]
[blueandgreen]
[redandwhite]
CD will now recalculate the number again on resolve
meaning {x}:target(CreatureTargetChooser[manacost <=x]) will work, with an added bonus {x}:target(CreatureTargetChooser[manacost <=any word variable])

new this(:
this(tapped)<--for strange case cards.
this(untapped)
this(auras)

new MTGAbility keywords
(blink)
(blink)forsrc <--stay blinked while source inplay
hand(blink <---adding hand to the front makes it target hand.

livingweapon
this is an extension of token, simple attach the words "livingweapon" to the front of token( and it will autoamtically token that and attach the card to it.

token( gained:
"targetcontroller" targetting.
"battleready" if put in the tokens abilities it will be a attacker and tapped as it is entering play.


phaseout <--self explanitory

spiritlink <--stacking lifelink style effect that benifits the OWNER of the card.
combatspiritlink same as above.

stacking flanking, requires 2 abilities unfortunately

[card]
name=Agility
target=creature
auto=teach(creature) flanker
auto=teach(creature) flanking
text=Enchant creature -- Enchanted creature gets +1/+1 and has flanking. (Whenever a creature without flanking blocks this creature, the blocking 
creature gets -1/-1 until end of turn.)
mana={1}{R}
type=Enchantment
subtype=Aura
[/card]

removeallcounters(number/number,name)
removes all counters of the type from a card, can all be
"all"
vampire hexmage effect.

added new tools for transforms
,setpower=number
,settoughness=number
removetypes

morph
autofacedown={0}:morph

eradicate <---same as the card name.

cumulativeupcost[ <--self explanitory

upcostmulti[ <--an upcost that will resolve with a && ability

phaseaction[ phase name ] ability

an ability that will trigger on the stated phase name.
also support for phaseactionmulti[

new triggers added:
@vampired( <--sengir vampire effect
@targeted( 
@lifeloss(
@lifed(

add a special ability builder called dynamicability
it acts alot like a choose your own adventure book

dynamicability<! variable 1, variable 2, variable 3,variable 4!> optional ability targetting the original target.

variable list 1:
this is the primary amount source
source
mytgt
myself
myfoe
variable list 2:
this is the variable we're after, or the amount
power
toughness
manacost
colors
age
charge
oneonecounters
thatmuch
variable list 3:
this is the main effect
strike
draw
lifeloss
lifegain
pumppow
pumptough
pumpboth
deplete
countersoneone
variable list 4:
how it will do this effect to.
itself
eachother
targetcontroller
targetopponent
tosrc
srccontroller
srcopponent

the best way to explain its usage is to look at cards coded with this ability. or experiment with combinations.

new gameoption
First turn player:player, opponent, random
who takes the first turn

added poisoned status, tho not complete since MBS hasnt spoiled enough cards to see where this variable will be used.

taught ai how to counter spell
improved ai, it will now cast instants during interupts and during your turn.
previously ai treated instant cards the same as it treated sorceries, which was not fair to the ai.

im sure there is some messed items, but the rev directly before this one had formatting in the code that created hundreds of conflicts with this one, so i had to dig this info out of red and green sections.

cards and test are coming soon, i ask PLEASE do not alter these new additions until the test are commited.
im commiting without the test because instead of allowing me to proceed with my beta test period, there are some that wish to rush me into a commit. if you do not like this commit revert it, i absolutely on no grounds give permission to recommit afterwards. and i will not recommit if a revert is called.
2011-01-21 20:18:56 +00:00

316 lines
11 KiB
C++

#include "PrecompiledHeader.h"
#include "GameStateOptions.h"
#include "GameApp.h"
#include "OptionItem.h"
#include "SimpleMenu.h"
#include "SimplePad.h"
#include "GameOptions.h"
#include "Translate.h"
namespace
{
const int kSaveAndBackToMainMenuID = 1;
const int kBackToMainMenuID = 2;
const int kNewProfileID = 4;
const int kReloadID = 5;
}
GameStateOptions::GameStateOptions(GameApp* parent) :
GameState(parent), mReload(false), grabber(NULL), optionsMenu(NULL), optionsTabs(NULL)
{
}
GameStateOptions::~GameStateOptions()
{
}
void GameStateOptions::Start()
{
newProfile = "";
timer = 0;
mState = SHOW_OPTIONS;
JRenderer::GetInstance()->EnableVSync(true);
WGuiList * optionsList;
optionsList = NEW WGuiList("Settings");
optionsList->Add(NEW WGuiHeader("General Options"));
if (GameApp::HasMusic)
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::MUSICVOLUME, "Music volume", 100, 10, 100),
OptionVolume::getInstance()));
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::SFXVOLUME, "SFX volume", 100, 10, 100), OptionVolume::getInstance()));
if (options[Options::DIFFICULTY_MODE_UNLOCKED].number)
{
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::DIFFICULTY, "Difficulty", 3, 1, 0),
OptionDifficulty::getInstance()));
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::ECON_DIFFICULTY, "Economic Difficuly", Constants::ECON_EASY)));
}
optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDS, "Seconds to pause for an Interrupt", 20, 1));
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYSPELLS, "Interrupt my spells"));
optionsList->Add(NEW OptionInteger(Options::INTERRUPTMYABILITIES, "Interrupt my abilities"));
optionsList->Add(NEW OptionInteger(Options::INTERRUPT_SECONDMAIN, "Interrupt opponent's end of turn"));
optionsTabs = NEW WGuiTabMenu();
optionsTabs->Add(optionsList);
optionsList = NEW WGuiList("Game");
optionsList->Add(NEW WGuiHeader("Interface Options"));
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::CLOSEDHAND, "Closed hand", 1, 1, 0)));
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::HANDDIRECTION, "Hand direction", 1, 1, 0)));
optionsList->Add(NEW WDecoEnum(NEW OptionInteger(Options::MANADISPLAY, "Mana display", 3, 1, 0)));
optionsList->Add(NEW OptionInteger(Options::REVERSETRIGGERS, "Reverse left and right triggers"));
optionsList->Add(NEW OptionInteger(Options::DISABLECARDS, "Disable card images"));
optionsList->Add(NEW OptionInteger(Options::TRANSITIONS, "Disable screen transitions"));
optionsList->Add(NEW OptionInteger(Options::OSD, "Display InGame extra information"));
optionsTabs->Add(optionsList);
optionsList = NEW WGuiList("User");
optionsList->Add(NEW WGuiHeader("User Options"));
WDecoConfirm * cPrf = NEW WDecoConfirm(this, NEW OptionProfile(mParent, this));
cPrf->confirm = "Use this Profile";
OptionThemeStyle * ots = NEW OptionThemeStyle("Theme Style");
OptionDirectory * od = NEW OptionTheme(ots);
WDecoConfirm * cThm = NEW WDecoConfirm(this, od);
cThm->confirm = "Use this Theme";
WDecoConfirm * cStyle = NEW WDecoConfirm(this, ots);
cStyle->confirm = "Use this Style";
optionsList->Add(NEW WGuiSplit(cPrf, cThm));
optionsList->Add(cStyle);
optionsList->Add(NEW WGuiButton(NEW WGuiHeader("New Profile"), -102, kNewProfileID, this));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODE, "Enable Cheat Mode")));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::OPTIMIZE_HAND, "Optimize Starting Hand")));
optionsList->Add(NEW WDecoCheat(NEW OptionInteger(Options::CHEATMODEAIDECK, "Unlock All Ai Decks")));
optionsTabs->Add(optionsList);
optionsList = NEW WGuiList("Advanced");
optionsList->Add(NEW WGuiHeader("Advanced Options"));
WDecoStyled * wAdv = NEW WDecoStyled(NEW WGuiHeader("The following options require a restart."));
wAdv->mStyle = WDecoStyled::DS_STYLE_ALERT;
optionsList->Add(wAdv);
WDecoConfirm * cLang = NEW WDecoConfirm(this, NEW OptionLanguage("Language"));
cLang->confirm = "Use this Language";
optionsList->Add(cLang);
WDecoEnum * oGra = NEW WDecoEnum(NEW OptionInteger(Options::MAX_GRADE, "Minimum Card Grade", Constants::GRADE_DANGEROUS, 1,
Constants::GRADE_BORDERLINE, "", Constants::GRADE_SUPPORTED));
optionsList->Add(oGra);
WDecoEnum * oASPhases = NEW WDecoEnum(NEW OptionInteger(Options::ASPHASES, "Phase Skip Automation", Constants::ASKIP_FULL, 1,
Constants::ASKIP_NONE, "", Constants::ASKIP_NONE));
optionsList->Add(oASPhases);
optionsTabs->Add(optionsList);
WDecoEnum * oFirstPlayer = NEW WDecoEnum(NEW OptionInteger(Options::FIRSTPLAYER, "First Turn Player", Constants::WHO_R, 1,
Constants::WHO_P, "", Constants::WHO_P));
optionsList->Add(oFirstPlayer);
optionsList = NEW WGuiKeyBinder("Key Bindings", this);
optionsTabs->Add(optionsList);
optionsList = NEW WGuiList("Credits");
optionsList->failMsg = "";
optionsTabs->Add(optionsList);
optionsMenu = NEW SimpleMenu(-102, this, Fonts::MENU_FONT, 50, 170);
optionsMenu->Add(kBackToMainMenuID, "Back to Main Menu");
optionsMenu->Add(kSaveAndBackToMainMenuID, "Save & Back to Main Menu");
optionsMenu->Add(kCancelMenuID, "Cancel");
optionsTabs->Entering(JGE_BTN_NONE);
}
void GameStateOptions::End()
{
JRenderer::GetInstance()->EnableVSync(false);
SAFE_DELETE(optionsTabs);
SAFE_DELETE(optionsMenu);
}
void GameStateOptions::Update(float dt)
{
timer += dt * 10;
if (options.keypadActive())
{
options.keypadUpdate(dt);
if (newProfile != "")
{
newProfile = options.keypadFinish();
if (newProfile != "")
{
options[Options::ACTIVE_PROFILE] = newProfile;
options.reloadProfile();
optionsTabs->Reload();
}
newProfile = "";
}
}
else
switch (mState)
{
default:
case SAVE:
switch (optionsTabs->needsConfirm())
{
case WGuiBase::CONFIRM_CANCEL:
mState = SHOW_OPTIONS;
break;
case WGuiBase::CONFIRM_OK:
optionsTabs->save();
JSoundSystem::GetInstance()->SetSfxVolume(options[Options::SFXVOLUME].number);
JSoundSystem::GetInstance()->SetMusicVolume(options[Options::MUSICVOLUME].number);
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
mState = SHOW_OPTIONS;
break;
case WGuiBase::CONFIRM_NEED:
optionsTabs->yieldFocus();
break;
}
// Note : No break here : must continue to continue updating the menu elements.
case SHOW_OPTIONS:
{
JGE* j = JGE::GetInstance();
JButton key;
if (grabber)
{
LocalKeySym sym;
if (LOCAL_KEY_NONE != (sym = j->ReadLocalKey()))
grabber->KeyPressed(sym);
}
else
while ((key = JGE::GetInstance()->ReadButton()))
{
if (!optionsTabs->CheckUserInput(key) && key == JGE_BTN_MENU)
mState = SHOW_OPTIONS_MENU;
}
optionsTabs->Update(dt);
break;
}
case SHOW_OPTIONS_MENU:
optionsMenu->Update(dt);
break;
}
if (mReload)
{
options.reloadProfile();
Translator::EndInstance();
Translator::GetInstance()->init();
optionsTabs->Reload();
mReload = false;
}
}
void GameStateOptions::Render()
{
//Erase
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
const char * const CreditsText[] = {
"Wagic, The Homebrew?! by Wololo",
"",
"updates, new cards, and more on http://wololo.net/wagic",
"Many thanks to the people who help this project",
"",
"",
"Art: Ilya B, Julio, Jeck, J, Kaioshin, Lakeesha",
"Check themeinfo.txt for the full credits of each theme!",
"",
"Dev Team:",
"Abrasax, almosthumane, Daddy32, DJardin, Dr.Solomat,",
"J, Jeck, Leungclj, linshier, Mootpoint, Mnguyen, Psyringe,",
"Salmelo, Superhiro, Wololo, Yeshua, Zethfox",
"",
"Music by Celestial Aeon Project, http://www.jamendo.com",
"",
"Deck Builders: Abrasax, AzureKnight, colarchon",
"Hehotfarv, Jeremy, Jog1118, JonyAS, Kaioshin",
"Lachaux, Link17, Muddobbers, Nakano, Niegen",
"Psyringe, r1c47, Superhiro, Szei, Thanatos02",
"Whismer, Wololo",
"",
"Thanks also go to Dr.Watson, Orine, Raphael, Sakya, Tyranid",
"for their help.",
"",
"Thanks to everyone who contributes code/content on the forums!",
"",
"Developed with the JGE++ Library (http://code.google.com/p/wagic)",
"SFX From www.soundsnap.com",
"",
"",
"This work is not related to or endorsed by Wizards of the Coast, Inc",
"",
"Please support this project with donations at http://wololo.net/wagic",
};
WFont * mFont = WResourceManager::Instance()->GetWFont(Fonts::MAGIC_FONT);
mFont->SetColor(ARGB(255,200,200,200));
mFont->SetScale(1.0);
float startpos = 272 - timer;
float pos = startpos;
int size = sizeof(CreditsText) / sizeof(CreditsText[0]);
for (int i = 0; i < size; i++)
{
pos = startpos + 20 * i;
if (pos > -20 && pos < SCREEN_HEIGHT + 20)
{
mFont->DrawString(CreditsText[i], SCREEN_WIDTH / 2, pos, JGETEXT_CENTER);
}
}
if (pos < -20)
timer = 0;
optionsTabs->Render();
if (mState == SHOW_OPTIONS_MENU)
optionsMenu->Render();
if (options.keypadActive())
options.keypadRender();
}
void GameStateOptions::ButtonPressed(int controllerId, int controlId)
{
//Exit menu?
if (controllerId == -102)
switch (controlId)
{
case kSaveAndBackToMainMenuID:
mState = SAVE;
break;
//Set Audio volume
case kBackToMainMenuID:
mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU);
break;
case kCancelMenuID:
mState = SHOW_OPTIONS;
break;
case kNewProfileID:
options.keypadStart("", &newProfile);
options.keypadTitle("New Profile");
break;
case kReloadID:
mReload = true;
break;
}
else
optionsTabs->ButtonPressed(controllerId, controlId);
}
;
void GameStateOptions::GrabKeyboard(KeybGrabber* g)
{
grabber = g;
}
void GameStateOptions::UngrabKeyboard(const KeybGrabber* g)
{
if (g == grabber)
grabber = NULL;
}