Psyringe - This revision adds "cheat mode", as suggested and pre-reviewed here:

http://wololo.net/forum/viewtopic.php?f=15&t=730

Although the feature is named "cheat mode", its main purpose is to provide a toolbox for content creators. Currently this means to help AI deck creators, but the cheat mode is easily extensible.

Features:
- To enable cheat mode, create a new profile with the super secret cheat name (shouldn't be hard to find - or just mail me if you don't want to look). Then, leave and re-enter the Options menu. You can now enable cheat mode on the first tab. Note: The secret profile name is *not* my original suggestion from the forum, I went with Jeck's alternative suggestion so that he won't have to cringe over bad puns everytime he's using it. ;)

- Complete collection: In cheat mode, there's a new option in the deck viewer, which makes sure that you have at least 4 of any card available.

- Deck integrity: When in cheat mode, and you load a deck with cards that are not present in your collection, then these cards won't be stripped from your deck any more. Instead, they are added to your collection.

- Money cheat: In cheat mode, when you click on an item in the shop, you get the option to steal 1,000 credits from the shopkeeper.

Please review my code - I just started with C++, I may make very obvious mistakes or use inelegant style. The sooner you point this out, the sooner I'll improve.

thanks to wololo and jeck for comments and suggestions.

Jeck: Do the setVisible and setHidden methods currently work? I tried to use them to hide a menu item, but they all seem to lead to empty methods - Perhaps placeholders for a not yet implemented functionality?
This commit is contained in:
Psyyringe
2009-11-02 04:27:14 +00:00
parent 7a108c3604
commit 779921a53f
7 changed files with 59 additions and 3 deletions

View File

@@ -95,10 +95,12 @@ void GameStateDeckViewer::Start()
stw.pageCount = 5;
stw.needUpdate = true;
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20);
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-150,20);
menu->Add(0,"Save");
menu->Add(1,"Save & Rename");
menu->Add(2,"Switch decks without saving");
if(options[Options::CHEATMODE].number)
menu->Add(-1,"Complete collection & reset (cheat)");
menu->Add(3,"Back to main menu");
menu->Add(4,"Cancel");
@@ -1096,13 +1098,20 @@ int GameStateDeckViewer::loadDeck(int deckid){
sprintf(deckname,"deck%i.txt",deckid);
SAFE_DELETE(myDeck);
myDeck = NEW DeckDataWrapper(NEW MTGDeck(options.profileFile(deckname,"",false,false).c_str(), mParent->collection));
// Check whether the cards in the deck are actually available in the player's collection:
MTGCard * current = myDeck->getNext();
int cheatmode = options[Options::CHEATMODE].number;
while (current){
int howmanyinDeck = myDeck->cards[current];
for (int i = 0; i < howmanyinDeck; i++){
int deleted = myCollection->Remove(current);
if (!deleted){
myDeck->Remove(current);
if (!deleted){ // Card was not present in the collection
if (cheatmode) { // (PSY) Are we in cheatmode?
playerdata->collection->add(current); // (PSY) Yes - add the card to the collection
} else {
myDeck->Remove(current); // No - remove the card from the deck
}
}
}
current = myDeck->getNext(current);
@@ -1173,6 +1182,11 @@ void GameStateDeckViewer::ButtonPressed(int controllerId, int controlId)
case 11: //Save / exit menu
switch (controlId)
{
case -1: // (PSY) Cheatmode: Complete the collection
playerdata->collection->complete(); // Add the cards
playerdata->collection->save(); // Save the new collection
mStage = STAGE_WELCOME; // Reset the deck viewer, so that the new collection gets loaded
break;
case 0:
myDeck->save();
playerdata->save();