This commit is contained in:
12
projects/mtg/Makefile
Normal file
12
projects/mtg/Makefile
Normal file
@@ -0,0 +1,12 @@
|
||||
all:
|
||||
$(MAKE) -f Makefile.1xx SCEkxploit
|
||||
|
||||
1xx:
|
||||
$(MAKE) -f Makefile.1xx SCEkxploit
|
||||
|
||||
3xx:
|
||||
$(MAKE) -f Makefile.3xx
|
||||
|
||||
clean:
|
||||
$(MAKE) -f Makefile.1xx clean
|
||||
$(MAKE) -f Makefile.3xx clean
|
||||
20
projects/mtg/Makefile.1xx
Normal file
20
projects/mtg/Makefile.1xx
Normal file
@@ -0,0 +1,20 @@
|
||||
TARGET = temp
|
||||
OBJS = src/ActionElement.o src/ActionLayer.o src/AIPlaer.o src/Blocker.o src/CardGui.o src/CardDescriptor.o src/ConstraintResolver.o src/Damage.o src/DuelLayers.o src/GameApp.o src/GameLauncher.o src/GameObserver.o src/GameStateDuel.o src/GroupOfCards.o src/GuiCardsController.o src/GuiLayers.o src/ManaCost.o src/MenuItem.o src/MTGAbility.o src/MTGCardInstance.o src/MTGCard.o src/MTGDeck.o src/MTGGamePhase.o src/MTGGameZones.o src/MTGGuiHand.o src/MTGGuiPlay.o src/Player.o src/SimpleMenuItem.o src/ActionStack.o src/Subtypes.o src/TargetChooser.o src/TexturesCache.o src/utils.o
|
||||
|
||||
|
||||
INCDIR = ../../JGE/include ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src
|
||||
CFLAGS = -O2 -G0 -Wall -g
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CXXFLAGS)
|
||||
|
||||
LIBDIR = ../../JGE/lib/psp
|
||||
LDFLAGS =
|
||||
LIBS = -ljge100 -lfreetype -lpng -lz -lm -lmikmod -lmmio -lpsppower -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lstdc++ -ljpeg -lgif -lpspaudiocodec -lpspmpeg
|
||||
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = MTG
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
|
||||
23
projects/mtg/Makefile.3xx
Normal file
23
projects/mtg/Makefile.3xx
Normal file
@@ -0,0 +1,23 @@
|
||||
TARGET = template
|
||||
OBJS = src/ActionElement.o src/ActionLayer.o src/ActionStack.o src/AIPlayer.o src/AIStats.o src/Blocker.o src/CardGui.o src/CardDescriptor.o src/CardDisplay.o src/ConstraintResolver.o src/Counters.o src/Damage.o src/DamagerDamaged.o src/DamageResolverLayer.o src/DeckDataWrapper.o src/DuelLayers.o src/GameApp.o src/GameLauncher.o src/GameObserver.o src/GameOptions.o src/GameStateDuel.o src/GameStateOptions.o src/GameStateShop.o src/GroupOfCards.o src/GuiCardsController.o src/GuiLayers.o src/Logger.o src/ManaCost.o src/ManaCostHybrid.o src/MenuItem.o src/MTGAbility.o src/MTGCardInstance.o src/MTGCard.o src/MTGDeck.o src/MTGGamePhase.o src/MTGGameZones.o src/MTGGuiHand.o src/MTGGuiPlay.o src/MTGRules.o src/OptionItem.o src/Player.o src/PlayerData.o src/PlayGuiObjectController.o src/PlayGuiObject.o src/PriceList.o src/ShopItem.o src/SimpleMenu.o src/SimpleMenuItem.o src/Subtypes.o src/TargetChooser.o src/TargetsList.o src/TexturesCache.o src/utils.o
|
||||
|
||||
|
||||
|
||||
BUILD_PRX = 1
|
||||
PSP_FW_VERSION=371
|
||||
|
||||
CFLAGS = -O2 -G0 -Wall -DDEVHOOK -DPSPFW3XX
|
||||
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
|
||||
ASFLAGS = $(CXXFLAGS)
|
||||
|
||||
INCDIR = ../../JGE/include ../../JGE/include/psp ../../JGE/include/psp/freetype2 ../../JGE/src
|
||||
LIBDIR = ../../JGE/lib/psp
|
||||
LDFLAGS =
|
||||
LIBS = -ljge300 -lhgetools -lfreetype -ljpeg -lgif -lpng -lz -lm -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lstdc++ -lpspfpu
|
||||
|
||||
EXTRA_TARGETS = EBOOT.PBP
|
||||
PSP_EBOOT_TITLE = WTH?!
|
||||
PSP_EBOOT_ICON = icon.png
|
||||
|
||||
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||
include $(PSPSDK)/lib/build.mak
|
||||
45
projects/mtg/bin/Res/test/_tests.txt
Normal file
45
projects/mtg/bin/Res/test/_tests.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
########################
|
||||
#Generic engine features
|
||||
########################
|
||||
generic/first_strike.txt
|
||||
generic/first_strike2.txt
|
||||
generic/first_strike3.txt
|
||||
generic/hybrid_mana.txt
|
||||
generic/legendary.txt
|
||||
generic/persist.txt
|
||||
generic/wither.txt
|
||||
########################
|
||||
#Specific Cards
|
||||
########################
|
||||
animate_dead.txt
|
||||
animate_dead2.txt
|
||||
ascendant_evincar.txt
|
||||
ascendant_evincar2.txt
|
||||
brass_man.txt
|
||||
castle.txt
|
||||
control_magic.txt
|
||||
counsel_of_the_soratami.txt
|
||||
counterspell.txt
|
||||
counterspell2.txt
|
||||
drain_life.txt
|
||||
goblin_balloon_brigade.txt
|
||||
goblin_balloon_brigade2.txt
|
||||
force_of_nature.txt
|
||||
force_of_nature2.txt
|
||||
force_of_nature3.txt
|
||||
giant_growth.txt
|
||||
keldon_warlord.txt
|
||||
kudzu.txt
|
||||
kudzu2.txt
|
||||
lifeforce.txt
|
||||
living_lands.txt
|
||||
lord_of_the_pit.txt
|
||||
lord_of_the_pit2.txt
|
||||
paralysis.txt
|
||||
paralysis2.txt
|
||||
resurrection.txt
|
||||
rootwalla.txt
|
||||
shivan_hellkite.txt
|
||||
shock.txt
|
||||
volcanic_island.txt
|
||||
white_knight1.txt
|
||||
20
projects/mtg/bin/Res/test/animate_dead.txt
Normal file
20
projects/mtg/bin/Res/test/animate_dead.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
#Testing Animate dead on a brass man in opponent's graveyard
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1143
|
||||
manapool:{B}{R}
|
||||
[PLAYER2]
|
||||
graveyard:1099
|
||||
[DO]
|
||||
1143
|
||||
1099
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1143,1099
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[END]
|
||||
42
projects/mtg/bin/Res/test/animate_dead2.txt
Normal file
42
projects/mtg/bin/Res/test/animate_dead2.txt
Normal file
@@ -0,0 +1,42 @@
|
||||
#Testing Animate dead on a fire elemental in opponent's graveyard, then testing if the elemental can be killed
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1143
|
||||
manapool:{B}{R}
|
||||
[PLAYER2]
|
||||
inplay:1239
|
||||
graveyard:1290
|
||||
[DO]
|
||||
1143
|
||||
1290
|
||||
eot
|
||||
#untap
|
||||
next
|
||||
#upkeep
|
||||
next
|
||||
#draw
|
||||
next
|
||||
#main 1
|
||||
next
|
||||
#cbt begins
|
||||
next
|
||||
#attackers
|
||||
1239
|
||||
next
|
||||
#defensers
|
||||
1290
|
||||
next
|
||||
#damage
|
||||
next
|
||||
#combat end
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
graveyard:1143
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
graveyard:1290,1239
|
||||
life:20
|
||||
[END]
|
||||
17
projects/mtg/bin/Res/test/ascendant_evincar.txt
Normal file
17
projects/mtg/bin/Res/test/ascendant_evincar.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
#Testing That Ascendant Evincar and Goblin King don't conflict
|
||||
#we put 1/1 red goblins in play, they should stay 1/1
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:106525,1296
|
||||
hand:1308
|
||||
manapool:{R}
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
1308
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:106525,1296,1308
|
||||
[PLAYER2]
|
||||
[END]
|
||||
17
projects/mtg/bin/Res/test/ascendant_evincar2.txt
Normal file
17
projects/mtg/bin/Res/test/ascendant_evincar2.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
#Testing That Ascendant Evincar and Goblin King don't conflict
|
||||
#we put 1/1 red goblins in play, they should stay 1/1
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1296,106525
|
||||
hand:1308
|
||||
manapool:{R}
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
1308
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1296,106525,1308
|
||||
[PLAYER2]
|
||||
[END]
|
||||
60
projects/mtg/bin/Res/test/brass_man.txt
Normal file
60
projects/mtg/bin/Res/test/brass_man.txt
Normal file
@@ -0,0 +1,60 @@
|
||||
#Testing That Brass Man untaps correctly for one mana
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1099,1387,1388
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[DO]
|
||||
1099
|
||||
next
|
||||
#blockers
|
||||
next
|
||||
#combatdamage
|
||||
next
|
||||
#endofcombat
|
||||
next
|
||||
#main phase 2
|
||||
next
|
||||
#eot
|
||||
next
|
||||
#cleanup
|
||||
next
|
||||
#untap 2
|
||||
next
|
||||
#upkeep 2
|
||||
next
|
||||
#draw 2
|
||||
next
|
||||
#main 2
|
||||
next
|
||||
#combatbegin 2
|
||||
next
|
||||
#attackers 2
|
||||
next
|
||||
#blockers 2
|
||||
next
|
||||
#combatdamage 2
|
||||
next
|
||||
#endofcombat 2
|
||||
next
|
||||
#main phase II 2
|
||||
next
|
||||
#eot 2
|
||||
next
|
||||
#cleanup 1
|
||||
next
|
||||
#untap 1
|
||||
next
|
||||
#upkeep 1
|
||||
1387
|
||||
1388
|
||||
1099
|
||||
[ASSERT]
|
||||
UPKEEP
|
||||
[PLAYER1]
|
||||
inplay:1099,1387,1388
|
||||
manapool:{G}
|
||||
[PLAYER2]
|
||||
life:19
|
||||
[END]
|
||||
37
projects/mtg/bin/Res/test/castle.txt
Normal file
37
projects/mtg/bin/Res/test/castle.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
#If Castle goes to graveyard, creatures should lose their bonus
|
||||
#Player one plays a disenchent on castle, then attacks with a 3/3 creature (hill giant)
|
||||
# will the grizzly bears (2/2, 2/4 with castle) survive ?
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1299
|
||||
hand:1343
|
||||
manapool:{1}{W}
|
||||
[PLAYER2]
|
||||
inplay:1334,1250
|
||||
[DO]
|
||||
1343
|
||||
1334
|
||||
next
|
||||
#combat beong
|
||||
next
|
||||
#attackers
|
||||
1299
|
||||
next
|
||||
#blockers
|
||||
1250
|
||||
next
|
||||
#combatdamage
|
||||
next
|
||||
#combatend
|
||||
1334
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:1299
|
||||
graveyard:1343
|
||||
life:20
|
||||
[PLAYER2]
|
||||
graveyard:1334,1250
|
||||
life:20
|
||||
[END]
|
||||
41
projects/mtg/bin/Res/test/control_magic.txt
Normal file
41
projects/mtg/bin/Res/test/control_magic.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
#Testing Control Magic on a fire elemental in opponent's play, then testing if the elemental can be killed
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1194
|
||||
manapool:{2}{U}{U}
|
||||
[PLAYER2]
|
||||
inplay:1239,1290
|
||||
[DO]
|
||||
1194
|
||||
1290
|
||||
eot
|
||||
#untap
|
||||
next
|
||||
#upkeep
|
||||
next
|
||||
#draw
|
||||
next
|
||||
#main 1
|
||||
next
|
||||
#cbt begins
|
||||
next
|
||||
#attackers
|
||||
1239
|
||||
next
|
||||
#defensers
|
||||
1290
|
||||
next
|
||||
#damage
|
||||
next
|
||||
#combat end
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
graveyard:1194
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
graveyard:1290,1239
|
||||
life:20
|
||||
[END]
|
||||
19
projects/mtg/bin/Res/test/counsel_of_the_soratami.txt
Normal file
19
projects/mtg/bin/Res/test/counsel_of_the_soratami.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
#Does Counsel of the soratami draw 2 cards ?
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:134757
|
||||
library:134758,135185,129882
|
||||
manapool:{2}{U}
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
134757
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:134757
|
||||
hand:129882,135185
|
||||
library:134758
|
||||
manapool:{0}
|
||||
[PLAYER2]
|
||||
[END]
|
||||
27
projects/mtg/bin/Res/test/counterspell.txt
Normal file
27
projects/mtg/bin/Res/test/counterspell.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
#Testing counterspell on bad moon
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1144
|
||||
manapool:{1}{B}
|
||||
[PLAYER2]
|
||||
hand:1196
|
||||
manapool:{U}{U}
|
||||
[DO]
|
||||
1144
|
||||
no
|
||||
yes
|
||||
1196
|
||||
1144
|
||||
endinterrupt
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:1144
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
graveyard:1196
|
||||
manapool:{0}
|
||||
life:20
|
||||
[END]
|
||||
44
projects/mtg/bin/Res/test/counterspell2.txt
Normal file
44
projects/mtg/bin/Res/test/counterspell2.txt
Normal file
@@ -0,0 +1,44 @@
|
||||
#Testing counterspell extensively
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1144,1157
|
||||
inplay:1373,1374,1386,1375
|
||||
[PLAYER2]
|
||||
hand:1196,129882
|
||||
inplay:1394,1393,129754,129607,129608
|
||||
[DO]
|
||||
1373
|
||||
1374
|
||||
1144
|
||||
no
|
||||
yes
|
||||
1394
|
||||
1393
|
||||
1196
|
||||
1144
|
||||
endinterruption
|
||||
1386
|
||||
1375
|
||||
1157
|
||||
no
|
||||
yes
|
||||
129754
|
||||
129607
|
||||
129608
|
||||
129882
|
||||
1157
|
||||
endinterruption
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:1144,1157
|
||||
inplay:1373,1374,1386,1375
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
graveyard:1196,129882
|
||||
inplay:1394,1393,129754,129607,129608
|
||||
manapool:{0}
|
||||
life:20
|
||||
[END]
|
||||
22
projects/mtg/bin/Res/test/drain_life.txt
Normal file
22
projects/mtg/bin/Res/test/drain_life.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
#Testing Drain life on a brass man
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1156
|
||||
manapool:{B}{B}{B}{B}{B}
|
||||
[PLAYER2]
|
||||
inplay:1099
|
||||
life:20
|
||||
[DO]
|
||||
1156
|
||||
1099
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:1156
|
||||
life:23
|
||||
manapool:{0}
|
||||
[PLAYER2]
|
||||
graveyard:1099
|
||||
life:20
|
||||
[END]
|
||||
26
projects/mtg/bin/Res/test/force_of_nature.txt
Normal file
26
projects/mtg/bin/Res/test/force_of_nature.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
#Testing That Force of nature does 8 damage if GGGG is not paid
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
life:20
|
||||
inplay:1245
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[DO]
|
||||
eot
|
||||
eot
|
||||
#untap 1
|
||||
next
|
||||
#upkeep 1
|
||||
next
|
||||
#draw 1
|
||||
next
|
||||
#main 1
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1245
|
||||
life:12
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[END]
|
||||
26
projects/mtg/bin/Res/test/force_of_nature2.txt
Normal file
26
projects/mtg/bin/Res/test/force_of_nature2.txt
Normal file
@@ -0,0 +1,26 @@
|
||||
#Testing That Force of nature accept GGGG to be paid
|
||||
[INIT]
|
||||
UNTAP
|
||||
[PLAYER1]
|
||||
life:20
|
||||
inplay:1245
|
||||
manapool:{G}{G}{G}{G}
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[DO]
|
||||
next
|
||||
#upkeep
|
||||
1245
|
||||
next
|
||||
#draw
|
||||
next
|
||||
#firstmain
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1245
|
||||
life:20
|
||||
manapool:{0}
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[END]
|
||||
23
projects/mtg/bin/Res/test/force_of_nature3.txt
Normal file
23
projects/mtg/bin/Res/test/force_of_nature3.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
#Testing That Force of nature does 8 damage if GGGG is not paid
|
||||
[INIT]
|
||||
UNTAP
|
||||
[PLAYER1]
|
||||
life:20
|
||||
inplay:1245
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[DO]
|
||||
next
|
||||
#upkeep 1
|
||||
next
|
||||
#draw 1
|
||||
next
|
||||
#main 1
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1245
|
||||
life:12
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[END]
|
||||
21
projects/mtg/bin/Res/test/generic/first_strike.txt
Normal file
21
projects/mtg/bin/Res/test/generic/first_strike.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
#Testing First Strike : white knight against grizzly bears
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1370
|
||||
[PLAYER2]
|
||||
inplay:1250
|
||||
[DO]
|
||||
1370
|
||||
next
|
||||
1250
|
||||
next
|
||||
next
|
||||
1370
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:1370
|
||||
[PLAYER2]
|
||||
graveyard:1250
|
||||
[END]
|
||||
21
projects/mtg/bin/Res/test/generic/first_strike2.txt
Normal file
21
projects/mtg/bin/Res/test/generic/first_strike2.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
#Testing First Strike : white knight against Fire Elemental : the white knight souldn't survive
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1370
|
||||
[PLAYER2]
|
||||
inplay:1290
|
||||
[DO]
|
||||
1370
|
||||
next
|
||||
1290
|
||||
next
|
||||
next
|
||||
1370
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
graveyard:1370
|
||||
[PLAYER2]
|
||||
inplay:1290
|
||||
[END]
|
||||
24
projects/mtg/bin/Res/test/generic/first_strike3.txt
Normal file
24
projects/mtg/bin/Res/test/generic/first_strike3.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
#Testing First Strike : white knight and grizzly bears attacksavannah lions
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1370, 1250
|
||||
[PLAYER2]
|
||||
life:20
|
||||
inplay:1365
|
||||
[DO]
|
||||
1370
|
||||
1250
|
||||
next
|
||||
1365
|
||||
next
|
||||
next
|
||||
1370
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:1370,1250
|
||||
[PLAYER2]
|
||||
graveyard:1365
|
||||
life:18
|
||||
[END]
|
||||
18
projects/mtg/bin/Res/test/generic/hybrid_mana.txt
Normal file
18
projects/mtg/bin/Res/test/generic/hybrid_mana.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
#Testing Hybrid Mana
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:157201
|
||||
manapool:{W}{R}{W}
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
157201
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:157201
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[END]
|
||||
18
projects/mtg/bin/Res/test/generic/legendary.txt
Normal file
18
projects/mtg/bin/Res/test/generic/legendary.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
#TestingLegendary with Ascendant Evincar
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:106525
|
||||
inplay:106525
|
||||
manapool:{4}{B}{B}
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
106525
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:106525,106525
|
||||
manapool:{0}
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[END]
|
||||
41
projects/mtg/bin/Res/test/generic/persist.txt
Normal file
41
projects/mtg/bin/Res/test/generic/persist.txt
Normal file
@@ -0,0 +1,41 @@
|
||||
#Testing Persist
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand: 1241
|
||||
manapool:{4}{G}{G}
|
||||
[PLAYER2]
|
||||
inplay:147437
|
||||
[DO]
|
||||
1241
|
||||
147437
|
||||
eot
|
||||
#untap 2
|
||||
next
|
||||
#upkeep 2
|
||||
next
|
||||
#draw2
|
||||
next
|
||||
#main2
|
||||
next
|
||||
#comba begins 2
|
||||
next
|
||||
#attackers
|
||||
147437
|
||||
next
|
||||
#blockers
|
||||
next
|
||||
#damages
|
||||
next
|
||||
#endofcombat
|
||||
1241
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
life:19
|
||||
graveyard:1241
|
||||
manapool:{0}
|
||||
[PLAYER2]
|
||||
inplay:147437
|
||||
life:20
|
||||
[END]
|
||||
51
projects/mtg/bin/Res/test/generic/wither.txt
Normal file
51
projects/mtg/bin/Res/test/generic/wither.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
#Testing Wither
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:153437
|
||||
[PLAYER2]
|
||||
inplay: 1250
|
||||
[DO]
|
||||
153437
|
||||
next
|
||||
#blockers
|
||||
1250
|
||||
next
|
||||
#combatdamage
|
||||
next
|
||||
#endofcombat
|
||||
next
|
||||
#main phase 2
|
||||
next
|
||||
#eot
|
||||
next
|
||||
#cleanup
|
||||
next
|
||||
#untap
|
||||
next
|
||||
#upkeep
|
||||
next
|
||||
#draw
|
||||
next
|
||||
#firstmain
|
||||
next
|
||||
#combatbegin
|
||||
next
|
||||
#attackers
|
||||
1250
|
||||
next
|
||||
#blockers
|
||||
next
|
||||
#damages
|
||||
next
|
||||
#endofcombat
|
||||
1250
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:153437
|
||||
life:19
|
||||
[PLAYER2]
|
||||
inplay:1250
|
||||
life:20
|
||||
[END]
|
||||
23
projects/mtg/bin/Res/test/goblin_balloon_brigade.txt
Normal file
23
projects/mtg/bin/Res/test/goblin_balloon_brigade.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
#Testing That Goblin Balloon brigade doesn't have flight by default
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1295
|
||||
[PLAYER2]
|
||||
life:20
|
||||
inplay:1302
|
||||
[DO]
|
||||
1295
|
||||
next
|
||||
1302
|
||||
next
|
||||
next
|
||||
1302
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
graveyard:1295
|
||||
[PLAYER2]
|
||||
graveyard:1302
|
||||
life:20
|
||||
[END]
|
||||
62
projects/mtg/bin/Res/test/goblin_balloon_brigade2.txt
Normal file
62
projects/mtg/bin/Res/test/goblin_balloon_brigade2.txt
Normal file
@@ -0,0 +1,62 @@
|
||||
#Testing That Goblin Balloon brigade doesn't have flight by default after one turn
|
||||
[INIT]
|
||||
CLEANUP
|
||||
[PLAYER1]
|
||||
inplay:1295
|
||||
[PLAYER2]
|
||||
life:20
|
||||
inplay:1302
|
||||
[DO]
|
||||
next
|
||||
#untap 2
|
||||
next
|
||||
#upkeep 2
|
||||
next
|
||||
#draw 2
|
||||
next
|
||||
#main 2
|
||||
next
|
||||
#combatbegin 2
|
||||
next
|
||||
#attackers 2
|
||||
next
|
||||
#blockers 2
|
||||
next
|
||||
#combatdamage 2
|
||||
next
|
||||
#endofcombat 2
|
||||
next
|
||||
#main phase II 2
|
||||
next
|
||||
#eot 2
|
||||
next
|
||||
#cleanup2
|
||||
next
|
||||
#untap
|
||||
next
|
||||
#upkeep
|
||||
next
|
||||
#draw
|
||||
next
|
||||
#firstmain
|
||||
next
|
||||
#combatbegin
|
||||
next
|
||||
#combatattackers
|
||||
1295
|
||||
next
|
||||
#blockers
|
||||
1302
|
||||
next
|
||||
#damage
|
||||
next
|
||||
#end
|
||||
1302
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
graveyard:1295
|
||||
[PLAYER2]
|
||||
graveyard:1302
|
||||
life:20
|
||||
[END]
|
||||
81
projects/mtg/bin/Res/test/keldon_warlord.txt
Normal file
81
projects/mtg/bin/Res/test/keldon_warlord.txt
Normal file
@@ -0,0 +1,81 @@
|
||||
#Testing That Keldon Warlord's power and toughness change as expected
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1308,1301
|
||||
[PLAYER2]
|
||||
life:20
|
||||
hand:1229
|
||||
inplay:1393
|
||||
[DO]
|
||||
1308
|
||||
1301
|
||||
next
|
||||
#blockers
|
||||
next
|
||||
#combatdamage
|
||||
next
|
||||
#endofcombat
|
||||
next
|
||||
#main phase II
|
||||
next
|
||||
#eot
|
||||
next
|
||||
#cleanup
|
||||
next
|
||||
#untap 2
|
||||
next
|
||||
#upkeep 2
|
||||
next
|
||||
#draw 2
|
||||
next
|
||||
#firstmain 2
|
||||
1393
|
||||
1229
|
||||
1308
|
||||
next
|
||||
#combatbegin 2
|
||||
next
|
||||
#combatattackers 2
|
||||
next
|
||||
#combatblockers 2
|
||||
next
|
||||
#combatdamage 2
|
||||
next
|
||||
#endofcombat 2
|
||||
next
|
||||
#main phase II 2
|
||||
next
|
||||
#eot 2
|
||||
next
|
||||
#cleanup 2
|
||||
next
|
||||
#untap
|
||||
next
|
||||
#upkeep
|
||||
next
|
||||
#draw
|
||||
next
|
||||
#firstmain
|
||||
next
|
||||
#combatbegin
|
||||
next
|
||||
#combatattackers
|
||||
1301
|
||||
next
|
||||
#combat blocker
|
||||
next
|
||||
#combat damage
|
||||
next
|
||||
#combat end
|
||||
1308
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
hand:1308
|
||||
inplay:1301
|
||||
[PLAYER2]
|
||||
graveyard:1229
|
||||
inplay:1393
|
||||
life:16
|
||||
[END]
|
||||
33
projects/mtg/bin/Res/test/kudzu.txt
Normal file
33
projects/mtg/bin/Res/test/kudzu.txt
Normal file
@@ -0,0 +1,33 @@
|
||||
#Testing Kudzu's effects
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1254
|
||||
manapool:{1}{G}{G}
|
||||
[PLAYER2]
|
||||
inplay:1391
|
||||
hand:1308
|
||||
[DO]
|
||||
1254
|
||||
1391
|
||||
eot
|
||||
#untap
|
||||
next
|
||||
#upkeep
|
||||
next
|
||||
#draw
|
||||
next
|
||||
#main 1
|
||||
1391
|
||||
1308
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:1254
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
graveyard:1391
|
||||
inplay:1308
|
||||
life:20
|
||||
[END]
|
||||
35
projects/mtg/bin/Res/test/kudzu2.txt
Normal file
35
projects/mtg/bin/Res/test/kudzu2.txt
Normal file
@@ -0,0 +1,35 @@
|
||||
#Testing Kudzu's effects
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1254
|
||||
inplay:1386
|
||||
manapool:{1}{G}{G}
|
||||
[PLAYER2]
|
||||
inplay:1391
|
||||
hand:1308
|
||||
[DO]
|
||||
1254
|
||||
1391
|
||||
eot
|
||||
#untap
|
||||
next
|
||||
#upkeep
|
||||
next
|
||||
#draw
|
||||
next
|
||||
#main 1
|
||||
1391
|
||||
1386
|
||||
1308
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1386,1254
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
graveyard:1391
|
||||
inplay:1308
|
||||
life:20
|
||||
[END]
|
||||
27
projects/mtg/bin/Res/test/lifeforce.txt
Normal file
27
projects/mtg/bin/Res/test/lifeforce.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
#Testing lifeforce on bad moon
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1144
|
||||
manapool:{1}{B}
|
||||
[PLAYER2]
|
||||
inplay:1256
|
||||
manapool:{G}{G}
|
||||
[DO]
|
||||
1144
|
||||
no
|
||||
yes
|
||||
1256
|
||||
1144
|
||||
endinterrupt
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:1144
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
inplay:1256
|
||||
manapool:{0}
|
||||
life:20
|
||||
[END]
|
||||
17
projects/mtg/bin/Res/test/living_lands.txt
Normal file
17
projects/mtg/bin/Res/test/living_lands.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
#Do Living Land give summoning sickness to lands ?
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1259
|
||||
hand:1386
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
1386
|
||||
1386
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1259,1386
|
||||
manapool:{G}
|
||||
[PLAYER2]
|
||||
[END]
|
||||
20
projects/mtg/bin/Res/test/lord_of_the_pit.txt
Normal file
20
projects/mtg/bin/Res/test/lord_of_the_pit.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
#Is Lord of the pit a black creature ?
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1166,1144
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
1166
|
||||
next
|
||||
next
|
||||
next
|
||||
1166
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:1166,1144
|
||||
life:20
|
||||
[PLAYER2]
|
||||
life:12
|
||||
[END]
|
||||
21
projects/mtg/bin/Res/test/lord_of_the_pit2.txt
Normal file
21
projects/mtg/bin/Res/test/lord_of_the_pit2.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
#Does lord of the pit deal damage only during my untap phases ?
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1166,1144
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
eot
|
||||
#player2's turn
|
||||
eot
|
||||
#player 1's turn
|
||||
eot
|
||||
#player2's turn
|
||||
[ASSERT]
|
||||
UNTAP
|
||||
[PLAYER1]
|
||||
inplay:1166,1144
|
||||
life:13
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[END]
|
||||
46
projects/mtg/bin/Res/test/paralysis.txt
Normal file
46
projects/mtg/bin/Res/test/paralysis.txt
Normal file
@@ -0,0 +1,46 @@
|
||||
#Testing That a Paralysed creature doesn't untap if nothing's done
|
||||
[INIT]
|
||||
SECONDMAIN
|
||||
[PLAYER1]
|
||||
hand:1171
|
||||
manapool:{B}
|
||||
[PLAYER2]
|
||||
life:20
|
||||
inplay:1250
|
||||
[DO]
|
||||
1171
|
||||
1250
|
||||
next
|
||||
#eot
|
||||
next
|
||||
#cleanup
|
||||
next
|
||||
#untap 2
|
||||
next
|
||||
#upkeep 2
|
||||
next
|
||||
#draw 2
|
||||
next
|
||||
#main 2
|
||||
next
|
||||
#combatbegin 2
|
||||
next
|
||||
#attackers 2
|
||||
1250
|
||||
next
|
||||
#blockers 2
|
||||
next
|
||||
#combatdamage 2
|
||||
next
|
||||
#endofcombat 2
|
||||
1250
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:1171
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
inplay:1250
|
||||
life:20
|
||||
[END]
|
||||
59
projects/mtg/bin/Res/test/paralysis2.txt
Normal file
59
projects/mtg/bin/Res/test/paralysis2.txt
Normal file
@@ -0,0 +1,59 @@
|
||||
#Testing That a Paralysed creature untaps if paralysis is removed
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1171
|
||||
manapool:{B}
|
||||
[PLAYER2]
|
||||
life:20
|
||||
hand:1343
|
||||
inplay:1250,129682,129681
|
||||
[DO]
|
||||
#Player 1 turn
|
||||
1171
|
||||
1250
|
||||
eot
|
||||
#Player 2 turn
|
||||
#untap 2
|
||||
next
|
||||
#upkeep 2
|
||||
next
|
||||
#draw 2
|
||||
next
|
||||
#main 2
|
||||
129682
|
||||
129681
|
||||
1343
|
||||
1171
|
||||
eot
|
||||
eot
|
||||
#Player2 turn
|
||||
#untap 2
|
||||
next
|
||||
#upkeep 2
|
||||
next
|
||||
#draw 2
|
||||
next
|
||||
#main 2
|
||||
next
|
||||
#combatbegin
|
||||
next
|
||||
#attackers
|
||||
1250
|
||||
next
|
||||
#blockers
|
||||
next
|
||||
#combatdamage
|
||||
next
|
||||
#combatend
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
graveyard:1171
|
||||
manapool:{0}
|
||||
life:18
|
||||
[PLAYER2]
|
||||
graveyard:1343
|
||||
inplay:1250,129682,129681
|
||||
life:20
|
||||
[END]
|
||||
21
projects/mtg/bin/Res/test/resurrection.txt
Normal file
21
projects/mtg/bin/Res/test/resurrection.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
#Testing resurrection on a brass man in my graveyard
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1360
|
||||
graveyard:1099
|
||||
manapool:{2}{W}{W}
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
1360
|
||||
1099
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:1099
|
||||
graveyard:1360
|
||||
manapool:{0}
|
||||
life:20
|
||||
[PLAYER2]
|
||||
life:20
|
||||
[END]
|
||||
32
projects/mtg/bin/Res/test/rootwalla.txt
Normal file
32
projects/mtg/bin/Res/test/rootwalla.txt
Normal file
@@ -0,0 +1,32 @@
|
||||
#Does the limit work well on Rootwalla's ability ?
|
||||
#player 1 tries to activate it twice. Does he get the manaburn because of the one time that didn't work ?
|
||||
#does player 2 get 4 damages ?
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
inplay:129707
|
||||
manapool:{G}{G}{G}{G}
|
||||
[PLAYER2]
|
||||
[DO]
|
||||
129707
|
||||
129707
|
||||
next
|
||||
#combat begin
|
||||
next
|
||||
#combat attackers
|
||||
129707
|
||||
next
|
||||
#combat blockers
|
||||
next
|
||||
#damages
|
||||
next
|
||||
#combatend
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
life:18
|
||||
inplay:129707
|
||||
manapool:{0}
|
||||
[PLAYER2]
|
||||
life:16
|
||||
[END]
|
||||
34
projects/mtg/bin/Res/test/shivan_hellkite.txt
Normal file
34
projects/mtg/bin/Res/test/shivan_hellkite.txt
Normal file
@@ -0,0 +1,34 @@
|
||||
#Does Shivan Hellkite ability tap it ? It shouldn't
|
||||
#trying its ability on a flying 2/2 creature
|
||||
[INIT]
|
||||
COMBATBEGIN
|
||||
[PLAYER1]
|
||||
inplay:130538
|
||||
manapool:{R}{R}{R}{R}
|
||||
[PLAYER2]
|
||||
inplay:129471
|
||||
[DO]
|
||||
130538
|
||||
129471
|
||||
130538
|
||||
129471
|
||||
next
|
||||
#attackers
|
||||
130538
|
||||
next
|
||||
#combat blockers
|
||||
129471
|
||||
#Actually this one should be dead...
|
||||
next
|
||||
#damages
|
||||
next
|
||||
#combatend
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:130538
|
||||
manapool:{0}
|
||||
[PLAYER2]
|
||||
life:15
|
||||
graveyard:129471
|
||||
[END]
|
||||
19
projects/mtg/bin/Res/test/shock.txt
Normal file
19
projects/mtg/bin/Res/test/shock.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
#Testing Does shock really do 2 damages (against a /2 creature) ?
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:129732
|
||||
manapool:{R}
|
||||
[PLAYER2]
|
||||
inplay:129471
|
||||
[DO]
|
||||
129732
|
||||
129471
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:129732
|
||||
manapool:{0}
|
||||
[PLAYER2]
|
||||
graveyard:129471
|
||||
[END]
|
||||
24
projects/mtg/bin/Res/test/volcanic_island.txt
Normal file
24
projects/mtg/bin/Res/test/volcanic_island.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
#Testing Volcanic Island
|
||||
[INIT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
hand:1231
|
||||
manapool:{U}{U}{U}{W}{W}
|
||||
[PLAYER2]
|
||||
inplay:1389,1390,1391
|
||||
[DO]
|
||||
1231
|
||||
1389
|
||||
1390
|
||||
1231
|
||||
[ASSERT]
|
||||
FIRSTMAIN
|
||||
[PLAYER1]
|
||||
graveyard:1231
|
||||
manapool:{0}
|
||||
life:18
|
||||
[PLAYER2]
|
||||
graveyard:1390,1389
|
||||
inplay:1391
|
||||
life:18
|
||||
[END]
|
||||
25
projects/mtg/bin/Res/test/white_knight1.txt
Normal file
25
projects/mtg/bin/Res/test/white_knight1.txt
Normal file
@@ -0,0 +1,25 @@
|
||||
#Testing First Strike : erg raiders and grizzly attack white kinght.
|
||||
# White knight has protection from black and gets no damage
|
||||
[INIT]
|
||||
COMBATATTACKERS
|
||||
[PLAYER1]
|
||||
inplay:1159, 1250
|
||||
[PLAYER2]
|
||||
life:20
|
||||
inplay:1370
|
||||
[DO]
|
||||
1159
|
||||
1250
|
||||
next
|
||||
1370
|
||||
next
|
||||
next
|
||||
1370
|
||||
[ASSERT]
|
||||
COMBATEND
|
||||
[PLAYER1]
|
||||
inplay:1159,1250
|
||||
[PLAYER2]
|
||||
inplay:1370
|
||||
life:18
|
||||
[END]
|
||||
BIN
projects/mtg/bin/fmod.dll
Normal file
BIN
projects/mtg/bin/fmod.dll
Normal file
Binary file not shown.
BIN
projects/mtg/bin/freetype6.dll
Normal file
BIN
projects/mtg/bin/freetype6.dll
Normal file
Binary file not shown.
BIN
projects/mtg/bin/giflib4.dll
Normal file
BIN
projects/mtg/bin/giflib4.dll
Normal file
Binary file not shown.
BIN
projects/mtg/bin/libpng13.dll
Normal file
BIN
projects/mtg/bin/libpng13.dll
Normal file
Binary file not shown.
BIN
projects/mtg/bin/zlib1.dll
Normal file
BIN
projects/mtg/bin/zlib1.dll
Normal file
Binary file not shown.
210
projects/mtg/extra/dirent.h
Normal file
210
projects/mtg/extra/dirent.h
Normal file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* dirent.h - dirent API for Microsoft Visual Studio
|
||||
*
|
||||
* Copyright (C) 2006 Toni Ronkko
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* ``Software''), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*
|
||||
* Jan 18, 2008, Toni Ronkko
|
||||
* Using FindFirstFileA and WIN32_FIND_DATAA to avoid converting string
|
||||
* between multi-byte and unicode representations. This makes the
|
||||
* code simpler and also allows the code to be compiled under MingW. Thanks
|
||||
* to Azriel Fasten for the suggestion.
|
||||
*
|
||||
* Mar 4, 2007, Toni Ronkko
|
||||
* Bug fix: due to the strncpy_s() function this file only compiled in
|
||||
* Visual Studio 2005. Using the new string functions only when the
|
||||
* compiler version allows.
|
||||
*
|
||||
* Nov 2, 2006, Toni Ronkko
|
||||
* Major update: removed support for Watcom C, MS-DOS and Turbo C to
|
||||
* simplify the file, updated the code to compile cleanly on Visual
|
||||
* Studio 2005 with both unicode and multi-byte character strings,
|
||||
* removed rewinddir() as it had a bug.
|
||||
*
|
||||
* Aug 20, 2006, Toni Ronkko
|
||||
* Removed all remarks about MSVC 1.0, which is antiqued now. Simplified
|
||||
* comments by removing SGML tags.
|
||||
*
|
||||
* May 14 2002, Toni Ronkko
|
||||
* Embedded the function definitions directly to the header so that no
|
||||
* source modules need to be included in the Visual Studio project. Removed
|
||||
* all the dependencies to other projects so that this very header can be
|
||||
* used independently.
|
||||
*
|
||||
* May 28 1998, Toni Ronkko
|
||||
* First version.
|
||||
*/
|
||||
#ifndef DIRENT_H
|
||||
#define DIRENT_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct dirent {
|
||||
/* name of current directory entry (a multi-byte character string) */
|
||||
char d_name[MAX_PATH + 1];
|
||||
|
||||
/* file attributes */
|
||||
WIN32_FIND_DATAA data;
|
||||
} dirent;
|
||||
|
||||
|
||||
typedef struct DIR {
|
||||
/* current directory entry */
|
||||
dirent current;
|
||||
|
||||
/* is there an un-processed entry in current? */
|
||||
int cached;
|
||||
|
||||
/* file search handle */
|
||||
HANDLE search_handle;
|
||||
|
||||
/* search pattern (3 = zero terminator + pattern "\\*") */
|
||||
char patt[MAX_PATH + 3];
|
||||
} DIR;
|
||||
|
||||
|
||||
static DIR *opendir (const char *dirname);
|
||||
static struct dirent *readdir (DIR *dirp);
|
||||
static int closedir (DIR *dirp);
|
||||
|
||||
|
||||
/* use the new safe string functions introduced in Visual Studio 2005 */
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
# define STRNCPY(dest,src,size) strncpy_s((dest),(size),(src),_TRUNCATE)
|
||||
#else
|
||||
# define STRNCPY(dest,src,size) strncpy((dest),(src),(size))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Open directory stream DIRNAME for read and return a pointer to the
|
||||
* internal working area that is used to retrieve individual directory
|
||||
* entries.
|
||||
*/
|
||||
static DIR*
|
||||
opendir(
|
||||
const char *dirname)
|
||||
{
|
||||
DIR *dirp;
|
||||
assert (dirname != NULL);
|
||||
assert (strlen (dirname) < MAX_PATH);
|
||||
|
||||
/* construct new DIR structure */
|
||||
dirp = (DIR*) malloc (sizeof (struct DIR));
|
||||
if (dirp != NULL) {
|
||||
char *p;
|
||||
|
||||
/* take directory name... */
|
||||
STRNCPY (dirp->patt, dirname, sizeof(dirp->patt));
|
||||
dirp->patt[MAX_PATH] = '\0';
|
||||
|
||||
/* ... and append search pattern to it */
|
||||
p = strchr (dirp->patt, '\0');
|
||||
if (dirp->patt < p && *(p-1) != '\\' && *(p-1) != ':') {
|
||||
*p++ = '\\';
|
||||
}
|
||||
*p++ = '*';
|
||||
*p = '\0';
|
||||
|
||||
/* open stream and retrieve first file */
|
||||
dirp->search_handle = FindFirstFileA (dirp->patt, &dirp->current.data);
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* invalid search pattern? */
|
||||
free (dirp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* there is an un-processed directory entry in memory now */
|
||||
dirp->cached = 1;
|
||||
|
||||
}
|
||||
return dirp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read a directory entry, and return a pointer to a dirent structure
|
||||
* containing the name of the entry in d_name field. Individual directory
|
||||
* entries returned by this very function include regular files,
|
||||
* sub-directories, pseudo-directories "." and "..", but also volume labels,
|
||||
* hidden files and system files may be returned.
|
||||
*/
|
||||
static struct dirent *
|
||||
readdir(
|
||||
DIR *dirp)
|
||||
{
|
||||
assert (dirp != NULL);
|
||||
|
||||
if (dirp->search_handle == INVALID_HANDLE_VALUE) {
|
||||
/* directory stream was opened/rewound incorrectly or it ended normally */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* get next directory entry */
|
||||
if (dirp->cached != 0) {
|
||||
/* a valid directory entry already in memory */
|
||||
dirp->cached = 0;
|
||||
} else {
|
||||
/* read next directory entry from disk */
|
||||
if (FindNextFileA (dirp->search_handle, &dirp->current.data) == FALSE) {
|
||||
/* the very last file has been processed or an error occured */
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy as a multibyte character string */
|
||||
STRNCPY (dirp->current.d_name, dirp->current.data.cFileName, sizeof(dirp->current.d_name));
|
||||
dirp->current.d_name[MAX_PATH] = '\0';
|
||||
|
||||
return &dirp->current;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Close directory stream opened by opendir() function. Close of the
|
||||
* directory stream invalidates the DIR structure as well as any previously
|
||||
* read directory entry.
|
||||
*/
|
||||
static int
|
||||
closedir(
|
||||
DIR *dirp)
|
||||
{
|
||||
assert (dirp != NULL);
|
||||
|
||||
/* release search handle */
|
||||
if (dirp->search_handle != INVALID_HANDLE_VALUE) {
|
||||
FindClose (dirp->search_handle);
|
||||
dirp->search_handle = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
/* release directory handle */
|
||||
free (dirp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /*DIRENT_H*/
|
||||
BIN
projects/mtg/icon.png
Normal file
BIN
projects/mtg/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
62
projects/mtg/include/AIPlayer.h
Normal file
62
projects/mtg/include/AIPlayer.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Wagic, The Homebrew ?! is licensed under the BSD license
|
||||
* See LICENSE in the Folder's root
|
||||
* http://wololo.net/wagic/
|
||||
*/
|
||||
|
||||
#ifndef _IAPLAYER_H
|
||||
#define _IAPLAYER_H
|
||||
|
||||
#include "Player.h"
|
||||
|
||||
|
||||
#define INFO_NBCREATURES 0
|
||||
#define INFO_CREATURESPOWER 1
|
||||
|
||||
|
||||
class AIStats;
|
||||
|
||||
class AIPlayer: public Player{
|
||||
protected:
|
||||
MTGCardInstance * nextCardToPlay;
|
||||
ManaCost * potentialMana;
|
||||
void tapLandsForMana(ManaCost * potentialMana, ManaCost * cost);
|
||||
int checkInterrupt();
|
||||
int combatDamages();
|
||||
int chooseAttackers();
|
||||
int chooseBlockers();
|
||||
int effectBadOrGood(MTGCardInstance * card);
|
||||
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
|
||||
AIStats * getStats();
|
||||
public:
|
||||
virtual int displayStack(){return 0;}
|
||||
AIStats * stats;
|
||||
ManaCost * getPotentialMana();
|
||||
AIPlayer(MTGPlayerCards * _deck, char * deckFile);
|
||||
virtual ~AIPlayer();
|
||||
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
|
||||
virtual int chooseTarget(TargetChooser * tc = NULL);
|
||||
virtual int Act();
|
||||
int isAI(){return 1;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
class AIPlayerBaka: public AIPlayer{
|
||||
protected:
|
||||
int oldGamePhase;
|
||||
int timer;
|
||||
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
|
||||
public:
|
||||
AIPlayerBaka(MTGPlayerCards * _deck, char * deckFile);
|
||||
virtual int Act();
|
||||
void initTimer();
|
||||
};
|
||||
|
||||
class AIPlayerFactory{
|
||||
public:
|
||||
AIPlayer * createAIPlayer(MTGAllCards * collection, MTGPlayerCards * oponents_deck);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
42
projects/mtg/include/AIStats.h
Normal file
42
projects/mtg/include/AIStats.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef _AISTATS_H_
|
||||
#define _AISTATS_H_
|
||||
|
||||
#define STATS_PLAYER_MULTIPLIER 15
|
||||
#define STATS_CREATURE_MULTIPLIER 10
|
||||
#define STATS_AURA_MULTIPLIER 9
|
||||
#include <list>
|
||||
#include <string>
|
||||
using std::list;
|
||||
using std::string;
|
||||
class Player;
|
||||
class MTGCardInstance;
|
||||
class MTGCard;
|
||||
class Damage;
|
||||
|
||||
class AIStat{
|
||||
public:
|
||||
int source; //MTGId of the card
|
||||
int value;
|
||||
int occurences;
|
||||
bool direct;
|
||||
AIStat(int _source, int _value, int _occurences, bool _direct):source(_source), value(_value),occurences(_occurences),direct(_direct){};
|
||||
};
|
||||
|
||||
|
||||
|
||||
class AIStats{
|
||||
public:
|
||||
Player * player;
|
||||
string filename;
|
||||
list<AIStat *> stats;
|
||||
AIStats(Player * _player, char * filename);
|
||||
~AIStats();
|
||||
void updateStats();
|
||||
void load(char * filename);
|
||||
void save();
|
||||
AIStat * find(MTGCard * card);
|
||||
bool isInTop(MTGCardInstance * card,int max, bool tooSmallCountsForTrue = true );
|
||||
void updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, float multiplier = 1.0);
|
||||
};
|
||||
|
||||
#endif
|
||||
48
projects/mtg/include/ActionElement.h
Normal file
48
projects/mtg/include/ActionElement.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Wagic, The Homebrew ?! is licensed under the BSD license
|
||||
* See LICENSE in the Folder's root
|
||||
* http://wololo.net/wagic/
|
||||
*/
|
||||
|
||||
#ifndef _ACTIONELEMENT_H_
|
||||
#define _ACTIONELEMENT_H_
|
||||
#include <JGui.h>
|
||||
|
||||
#define INACTIVE 0
|
||||
#define ACTION_REQUESTED 1
|
||||
#define ACTIVE 2
|
||||
|
||||
|
||||
class MTGCardInstance;
|
||||
class Targetable;
|
||||
class TargetChooser;
|
||||
|
||||
class ActionElement: public JGuiObject{
|
||||
protected:
|
||||
int activeState;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
TargetChooser * tc;
|
||||
int currentPhase;
|
||||
int newPhase;
|
||||
int modal;
|
||||
int waitingForAnswer;
|
||||
void RenderMessageBackground(float y0, int height);
|
||||
int getActivity();
|
||||
virtual void Update(float dt){};
|
||||
virtual void Render(){};
|
||||
virtual int testDestroy(){return 0;};
|
||||
virtual int destroy(){return 0;};
|
||||
virtual void CheckUserInput(float dt){};
|
||||
ActionElement(int id);
|
||||
virtual int isReactingToTargetClick(Targetable * card);
|
||||
virtual int reactToTargetClick(Targetable * card);
|
||||
virtual int isReactingToClick(MTGCardInstance * card){return 0;};
|
||||
virtual int reactToClick(MTGCardInstance * card){return 0;};
|
||||
virtual const char * getMenuText(){return "Ability";};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
39
projects/mtg/include/ActionLayer.h
Normal file
39
projects/mtg/include/ActionLayer.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Wagic, The Homebrew ?! is licensed under the BSD license
|
||||
* See LICENSE in the Folder's root
|
||||
* http://wololo.net/wagic/
|
||||
*/
|
||||
|
||||
#ifndef _ACTIONLAYER_H_
|
||||
#define _ACTIONLAYER_H_
|
||||
|
||||
#include "GuiLayers.h"
|
||||
#include "ActionElement.h"
|
||||
#include "SimpleMenu.h"
|
||||
|
||||
class GuiLayer;
|
||||
class Targetable;
|
||||
|
||||
class ActionLayer: public GuiLayer, public JGuiListener{
|
||||
public:
|
||||
Targetable * menuObject;
|
||||
SimpleMenu * abilitiesMenu;
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
int unstopableRenderInProgress();
|
||||
void CheckUserInput(float dt);
|
||||
ActionLayer(int id, GameObserver* _game):GuiLayer(id, _game){ menuObject = NULL; abilitiesMenu = NULL;};
|
||||
int isWaitingForAnswer();
|
||||
int isReactingToTargetClick(Targetable * card);
|
||||
int reactToTargetClick(Targetable * card);
|
||||
int isReactingToClick(MTGCardInstance * card);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int isModal();
|
||||
void setMenuObject(Targetable * object);
|
||||
void ButtonPressed(int controllerid, int controlid);
|
||||
TargetChooser * getCurrentTargetChooser();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
151
projects/mtg/include/ActionStack.h
Normal file
151
projects/mtg/include/ActionStack.h
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* Wagic, The Homebrew ?! is licensed under the BSD license
|
||||
* See LICENSE in the Folder's root
|
||||
* http://wololo.net/wagic/
|
||||
*/
|
||||
|
||||
#ifndef _SPELLSTACK_H_
|
||||
#define _SPELLSTACK_H_
|
||||
|
||||
#define MAX_SPELL_TARGETS 10
|
||||
|
||||
|
||||
#define ACTION_SPELL 10
|
||||
#define ACTION_DAMAGE 11
|
||||
#define ACTION_DAMAGES 12
|
||||
#define ACTION_NEXTGAMEPHASE 13
|
||||
#define ACTION_DRAW 14
|
||||
#define ACTION_PUTINGRAVEYARD 15
|
||||
#define ACTION_ABILITY 16
|
||||
|
||||
#define NOT_RESOLVED -2
|
||||
#define RESOLVED_OK 1
|
||||
#define RESOLVED_NOK -1
|
||||
|
||||
#include "../include/PlayGuiObject.h"
|
||||
#include "GuiLayers.h"
|
||||
#include "../include/TargetsList.h"
|
||||
#include "../include/Targetable.h"
|
||||
|
||||
class GuiLayer;
|
||||
class PlayGuiObject;
|
||||
class MTGCardInstance;
|
||||
class GameObserver;
|
||||
class Player;
|
||||
class Damageable;
|
||||
class MTGAbility;
|
||||
class Targetable;
|
||||
class DamageStack;
|
||||
class ManaCost;
|
||||
|
||||
|
||||
#define ACTIONSTACK_STANDARD 0
|
||||
#define ACTIONSTACK_TARGET 1
|
||||
|
||||
class Interruptible: public PlayGuiObject, public Targetable{
|
||||
public:
|
||||
int state, display;
|
||||
MTGCardInstance * source;
|
||||
virtual void Entering(){mHasFocus = true;};
|
||||
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
|
||||
virtual bool ButtonPressed(){return true;};
|
||||
virtual int resolve(){return 0;};
|
||||
virtual void Render(){};
|
||||
int typeAsTarget(){return TARGET_STACKACTION;};
|
||||
Interruptible(int id,bool hasFocus = false):PlayGuiObject(id,40,x,y,hasFocus){state=NOT_RESOLVED;display=0;source=NULL;};
|
||||
};
|
||||
|
||||
class NextGamePhase: public Interruptible {
|
||||
public:
|
||||
int resolve();
|
||||
void Render();
|
||||
NextGamePhase(int id);
|
||||
};
|
||||
|
||||
class Spell: public Interruptible, public TargetsList {
|
||||
protected:
|
||||
|
||||
public:
|
||||
ManaCost * cost;
|
||||
Spell(MTGCardInstance* _source);
|
||||
Spell(int id, MTGCardInstance* _source, Targetable * _targets[], int _nbtargets, ManaCost * _cost);
|
||||
~Spell();
|
||||
int resolve();
|
||||
void Render();
|
||||
};
|
||||
|
||||
class StackAbility: public Interruptible {
|
||||
public:
|
||||
MTGAbility * ability;
|
||||
int resolve();
|
||||
void Render();
|
||||
StackAbility(int id, MTGAbility * _ability);
|
||||
};
|
||||
|
||||
class PutInGraveyard: public Interruptible {
|
||||
public:
|
||||
MTGCardInstance * card;
|
||||
int removeFromGame;
|
||||
int resolve();
|
||||
void Render();
|
||||
PutInGraveyard(int id, MTGCardInstance * _card);
|
||||
};
|
||||
|
||||
|
||||
class DrawAction: public Interruptible {
|
||||
public:
|
||||
int nbcards;
|
||||
Player * player;
|
||||
int resolve();
|
||||
void Render();
|
||||
DrawAction(int id, Player * _player, int _nbcards);
|
||||
};
|
||||
|
||||
class ActionStack :public GuiLayer{
|
||||
protected:
|
||||
int interruptDecision[2];
|
||||
int timer;
|
||||
int currentState;
|
||||
int mode;
|
||||
int checked;
|
||||
|
||||
|
||||
void unpackDamageStacks();
|
||||
void unpackDamageStack(DamageStack * ds);
|
||||
void repackDamageStacks();
|
||||
public:
|
||||
int setIsInterrupting(Player * player);
|
||||
int count( int type = 0 , int state = 0 , int display = -1);
|
||||
Interruptible * getPrevious(Interruptible * next, int type = 0, int state = 0 , int display = -1);
|
||||
int getPreviousIndex(Interruptible * next, int type = 0, int state = 0 , int display = -1);
|
||||
Interruptible * getNext(Interruptible * previous, int type = 0, int state = 0 , int display = -1);
|
||||
int getNextIndex(Interruptible * previous, int type = 0, int state = 0 , int display = -1);
|
||||
void Fizzle(Interruptible * action);
|
||||
Interruptible * _(int id);
|
||||
void cancelInterruptOffer(int cancelMode = 1);
|
||||
void endOfInterruption();
|
||||
Interruptible * getLatest(int state);
|
||||
Player * askIfWishesToInterrupt;
|
||||
int garbageCollect();
|
||||
int addAction(Interruptible * interruptible);
|
||||
int addSpell(MTGCardInstance* card, Targetable * targets[], int nbtargets, ManaCost * mana);
|
||||
int AddNextGamePhase();
|
||||
int addPutInGraveyard(MTGCardInstance * card);
|
||||
int addDraw(Player * player, int nbcards = 1);
|
||||
int addDamage(MTGCardInstance * _source, Damageable * target, int _damage);
|
||||
int addAbility(MTGAbility * ability);
|
||||
void Update(float dt);
|
||||
void CheckUserInput(float dt);
|
||||
virtual void Render();
|
||||
ActionStack(int id, GameObserver* _game);
|
||||
int resolve();
|
||||
int CombatDamages();
|
||||
int CombatDamages(int firststrike);
|
||||
int has(Interruptible * action);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
2735
projects/mtg/include/AllAbilities.h
Normal file
2735
projects/mtg/include/AllAbilities.h
Normal file
File diff suppressed because it is too large
Load Diff
53
projects/mtg/include/Blocker.h
Normal file
53
projects/mtg/include/Blocker.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef _BLOCKER_H_
|
||||
#define _BLOCKER_H_
|
||||
|
||||
|
||||
#define MAX_BLOCKERS 64 // Currently needs to be equal to MAX_GUI_OBJECTS in JGE/JGui.h.
|
||||
|
||||
|
||||
#include "MTGAbility.h"
|
||||
|
||||
|
||||
class ManaCost;
|
||||
class GameObserver;
|
||||
class MTGAbility;
|
||||
|
||||
class Blocker : public MTGAbility {
|
||||
protected:
|
||||
ManaCost * manaCost;
|
||||
int currentPhase;
|
||||
void init(ManaCost * _cost);
|
||||
public:
|
||||
virtual ManaCost * untapManaCost(){return manaCost;};
|
||||
virtual int unblock(){return 1;};
|
||||
Blocker(int id, MTGCardInstance * card, ManaCost * _cost);
|
||||
Blocker(int id, MTGCardInstance * card);
|
||||
Blocker(int id, MTGCardInstance * card, MTGCardInstance *_target, ManaCost * _cost);
|
||||
~Blocker();
|
||||
virtual void Update(float dt);
|
||||
virtual int destroy();
|
||||
};
|
||||
|
||||
|
||||
class Blockers {
|
||||
protected:
|
||||
int cursor;
|
||||
int blockers[MAX_BLOCKERS];
|
||||
GameObserver * game;
|
||||
public:
|
||||
Blockers();
|
||||
~Blockers();
|
||||
int Add (Blocker * ability);
|
||||
int Remove (Blocker * ability);
|
||||
int init();
|
||||
Blocker * next();
|
||||
int rewind();
|
||||
int isEmpty();
|
||||
};
|
||||
|
||||
|
||||
#include "ManaCost.h"
|
||||
#include "GameObserver.h"
|
||||
|
||||
#endif
|
||||
|
||||
22
projects/mtg/include/CardDescriptor.h
Normal file
22
projects/mtg/include/CardDescriptor.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
A Filter/Mask system for Card Instances to find cards matching specific settings such as color, type, etc...
|
||||
*/
|
||||
|
||||
#ifndef _CARDDESCRIPTOR_H_
|
||||
#define _CARDDESCRIPTOR_H_
|
||||
|
||||
#include "MTGCardInstance.h"
|
||||
#include "MTGGameZones.h"
|
||||
|
||||
class CardDescriptor: public MTGCardInstance{
|
||||
protected:
|
||||
|
||||
public:
|
||||
int init();
|
||||
CardDescriptor();
|
||||
MTGCardInstance * match(MTGCardInstance * card);
|
||||
MTGCardInstance * match(MTGGameZone * zone);
|
||||
MTGCardInstance * nextmatch(MTGGameZone * zone, MTGCardInstance * previous);
|
||||
};
|
||||
|
||||
#endif
|
||||
32
projects/mtg/include/CardDisplay.h
Normal file
32
projects/mtg/include/CardDisplay.h
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _CARD_DISPLAY_H_
|
||||
#define _CARD_DISPLAY_H_
|
||||
|
||||
#include "../include/PlayGuiObjectController.h"
|
||||
|
||||
class TargetChooser;
|
||||
class MTGGameZone;
|
||||
class MTGCardInstance;
|
||||
|
||||
class CardDisplay:public PlayGuiObjectController{
|
||||
public:
|
||||
int x, y , start_item, nb_displayed_items;
|
||||
TargetChooser * tc;
|
||||
JGuiListener * listener;
|
||||
CardDisplay();
|
||||
CardDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, TargetChooser * _tc = NULL, int _nb_displayed_items = 7 );
|
||||
void AddCard(MTGCardInstance * _card);
|
||||
void rotateLeft();
|
||||
void rotateRight();
|
||||
void CheckUserInput(float dt);
|
||||
void Render();
|
||||
void init(MTGGameZone * zone);
|
||||
};
|
||||
|
||||
|
||||
|
||||
class DefaultTargetDisplay:CardDisplay{
|
||||
public:
|
||||
DefaultTargetDisplay(int id, GameObserver* _game, int _x, int _y, JGuiListener * _listener, int _nb_displayed_items );
|
||||
~DefaultTargetDisplay();
|
||||
};
|
||||
#endif
|
||||
30
projects/mtg/include/CardGui.h
Normal file
30
projects/mtg/include/CardGui.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Graphical representation of a Card Instance, used in game */
|
||||
|
||||
#ifndef _CARD_GUI_H_
|
||||
#define _CARD_GUI_H_
|
||||
|
||||
#include <JGui.h>
|
||||
#include "PlayGuiObject.h"
|
||||
#include "MTGCardInstance.h"
|
||||
#include <hge/hgeparticle.h>
|
||||
|
||||
class MTGCardInstance;
|
||||
class PlayGuiObject;
|
||||
|
||||
class CardGui: public PlayGuiObject{
|
||||
protected:
|
||||
hgeParticleSystem * mParticleSys;
|
||||
int alpha;
|
||||
public:
|
||||
MTGCardInstance * card;
|
||||
CardGui(int id, MTGCardInstance * _card, float desiredHeight, float _x=0, float _y=0, bool hasFocus = false);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
void RenderBig(float x=-1, float y = -1);
|
||||
static void alternateRender(MTGCard * card, JLBFont * mFont, JQuad ** manaIcons, float x, float y, float rotation= 0, float scale=1);
|
||||
~CardGui();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
14
projects/mtg/include/ConstraintResolver.h
Normal file
14
projects/mtg/include/ConstraintResolver.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef _CONSTRAINTRESOLVER_H_
|
||||
#define _CONSTRAINTRESOLVER_H_
|
||||
|
||||
#include "GameObserver.h"
|
||||
#include "MTGCardInstance.h"
|
||||
|
||||
|
||||
class ConstraintResolver {
|
||||
protected:
|
||||
public:
|
||||
static int untap(GameObserver * game, MTGCardInstance * card);
|
||||
};
|
||||
|
||||
#endif
|
||||
43
projects/mtg/include/Counters.h
Normal file
43
projects/mtg/include/Counters.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef _COUNTERS_H_
|
||||
#define _COUNTERS_H_
|
||||
#include <string>
|
||||
|
||||
|
||||
using std::string;
|
||||
class MTGCardInstance;
|
||||
|
||||
/* One family of counters. Ex : +1/+1 */
|
||||
class Counter{
|
||||
public :
|
||||
string name;
|
||||
int nb;
|
||||
int power, toughness;
|
||||
MTGCardInstance * target;
|
||||
Counter(MTGCardInstance * _target, int _power, int _toughness);
|
||||
Counter(MTGCardInstance * _target, const char * _name,int _power = 0 , int _toughness = 0 );
|
||||
int init(MTGCardInstance * _target,const char * _name, int _power, int _toughness);
|
||||
bool sameAs(const char * _name, int _power, int _toughness);
|
||||
bool cancels(int _power, int _toughness);
|
||||
int added();
|
||||
int removed();
|
||||
};
|
||||
|
||||
/* Various families of counters attached to an instance of a card */
|
||||
class Counters{
|
||||
public:
|
||||
int mCount;
|
||||
Counter * counters[10];
|
||||
MTGCardInstance * target;
|
||||
Counters(MTGCardInstance * _target);
|
||||
~Counters();
|
||||
int addCounter(const char * _name,int _power = 0, int _toughness = 0);
|
||||
int addCounter(int _power, int _toughness);
|
||||
int removeCounter(const char * _name,int _power = 0, int _toughness = 0);
|
||||
int removeCounter(int _power, int _toughness);
|
||||
Counter * hasCounter(const char * _name,int _power = 0, int _toughness = 0);
|
||||
Counter * hasCounter(int _power, int _toughness);
|
||||
Counter * getNext(Counter * previous = NULL);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
58
projects/mtg/include/Damage.h
Normal file
58
projects/mtg/include/Damage.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef _DAMAGE_H_
|
||||
#define _DAMAGE_H_
|
||||
|
||||
#include <JGui.h>
|
||||
#include "GuiLayers.h"
|
||||
#include "ActionStack.h"
|
||||
|
||||
class GuiLayer;
|
||||
class JGuiObject;
|
||||
class MTGCardInstance;
|
||||
class GameObserver;
|
||||
|
||||
#define DAMAGEABLE_MTGCARDINSTANCE 0
|
||||
#define DAMAGEABLE_PLAYER 1
|
||||
|
||||
class Damageable {
|
||||
protected:
|
||||
|
||||
public:
|
||||
int life;
|
||||
int type_as_damageable;
|
||||
Damageable(int _life){life=_life;};
|
||||
int getLife(){return life;};
|
||||
virtual int dealDamage(int damage){life-=damage;return life;};
|
||||
virtual int afterDamage(){return 0;}
|
||||
virtual JQuad * getIcon(){return NULL;};
|
||||
};
|
||||
|
||||
class Damage: public Interruptible {
|
||||
protected:
|
||||
void init(MTGCardInstance * _source, Damageable * _target, int _damage);
|
||||
public:
|
||||
Damageable * target;
|
||||
MTGCardInstance * source;
|
||||
int damage;
|
||||
void Render();
|
||||
Damage(int id, MTGCardInstance* _source, Damageable * _target);
|
||||
Damage(int id, MTGCardInstance* _source, Damageable * _target, int _damage);
|
||||
int resolve();
|
||||
};
|
||||
|
||||
|
||||
class DamageStack :public GuiLayer, public Interruptible{
|
||||
protected:
|
||||
int currentState;
|
||||
|
||||
|
||||
public:
|
||||
int resolve();
|
||||
void Render();
|
||||
int CombatDamages();//Deprecated ?
|
||||
int CombatDamages(int strike);
|
||||
DamageStack(int id, GameObserver* _game);
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
38
projects/mtg/include/DamageResolverLayer.h
Normal file
38
projects/mtg/include/DamageResolverLayer.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef _DAMAGERESOLVERLAYER_H_
|
||||
#define _DAMAGERESOLVERLAYER_H_
|
||||
#include "../include/PlayGuiObjectController.h"
|
||||
|
||||
class MTGCardInstance;
|
||||
class DamagerDamaged;
|
||||
class DamageStack;
|
||||
|
||||
|
||||
class DamageResolverLayer:public PlayGuiObjectController{
|
||||
protected:
|
||||
int trampleDamage();
|
||||
public:
|
||||
int buttonOk;
|
||||
int currentPhase;
|
||||
int remainingDamageSteps;
|
||||
Player * currentChoosingPlayer;
|
||||
DamageStack * damageStack;
|
||||
DamagerDamaged * currentSource;
|
||||
|
||||
DamageResolverLayer(int id, GameObserver* _game);
|
||||
int init();
|
||||
int initResolve();
|
||||
Player * whoSelectsDamagesDealtBy(MTGCardInstance * card);
|
||||
int addAutoDamageToOpponents(MTGCardInstance * card);
|
||||
int addIfNotExists(MTGCardInstance * card, Player * selecter);
|
||||
int addDamager(MTGCardInstance * card, Player * selecter);
|
||||
DamagerDamaged * findByCard(MTGCardInstance * card);
|
||||
int canStopDealDamages();
|
||||
int resolveDamages();
|
||||
int isOpponent(DamagerDamaged * a, DamagerDamaged * b);
|
||||
void nextPlayer();
|
||||
virtual void Update(float dt);
|
||||
virtual void CheckUserInput(float dt);
|
||||
virtual void Render();
|
||||
};
|
||||
|
||||
#endif
|
||||
30
projects/mtg/include/DamagerDamaged.h
Normal file
30
projects/mtg/include/DamagerDamaged.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _DAMAGERDAMAGED_H_
|
||||
#define _DAMAGERDAMAGED_H_
|
||||
|
||||
#include "../include/CardGui.h"
|
||||
|
||||
class Player;
|
||||
|
||||
class DamagerDamaged:public CardGui{
|
||||
public:
|
||||
Player * damageSelecter;
|
||||
int mCount;
|
||||
Damage * damages[10];
|
||||
int damageToDeal;
|
||||
|
||||
int dealOneDamage(DamagerDamaged * target);
|
||||
int addDamage(int damage, DamagerDamaged * source);
|
||||
int removeDamagesTo(DamagerDamaged * target);
|
||||
int removeDamagesFrom(DamagerDamaged * source);
|
||||
int sumDamages();
|
||||
int hasLethalDamage();
|
||||
DamagerDamaged(CardGui * cardg, Player * _damageSelecter, bool _hasFocus);
|
||||
~DamagerDamaged();
|
||||
void Render(Player * currentPlayer);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
48
projects/mtg/include/DeckDataWrapper.h
Normal file
48
projects/mtg/include/DeckDataWrapper.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _DECKDATAWRAPPER_H_
|
||||
#define _DECKDATAWRAPPER_H_
|
||||
|
||||
#include "../include/MTGDefinitions.h"
|
||||
#include "../include/MTGCard.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
using std::map;
|
||||
using std::string;
|
||||
|
||||
class MTGDeck;
|
||||
|
||||
|
||||
class Cmp1 { // compares cards by their name
|
||||
public:
|
||||
bool operator()(MTGCard * card1, MTGCard * card2) {
|
||||
if (!card2) return true;
|
||||
if (!card1) return false;
|
||||
string name1 = card1->name;
|
||||
string name2 = card2->name;
|
||||
int result = name1.compare(name2);
|
||||
if (!result) return card1->getMTGId() < card2->getMTGId();
|
||||
return ( result < 0);
|
||||
}
|
||||
};
|
||||
|
||||
class DeckDataWrapper{
|
||||
public:
|
||||
int colors[MTG_NB_COLORS+1];
|
||||
int currentColor;
|
||||
map<MTGCard *, int,Cmp1> cards;
|
||||
int currentposition;
|
||||
MTGDeck * parent;
|
||||
|
||||
DeckDataWrapper(MTGDeck * deck);
|
||||
~DeckDataWrapper();
|
||||
|
||||
int Add(MTGCard * card);
|
||||
int Remove(MTGCard * card);
|
||||
MTGCard * getNext(MTGCard * previous = NULL, int color = -1);
|
||||
MTGCard * getPrevious(MTGCard * next = NULL, int color = -1);
|
||||
void updateCounts(MTGCard * card = NULL, int removed = 0);
|
||||
void updateCurrentPosition(MTGCard * currentCard,int color = -1);
|
||||
int getCount(int color = -1);
|
||||
void save();
|
||||
};
|
||||
|
||||
#endif
|
||||
34
projects/mtg/include/DuelLayers.h
Normal file
34
projects/mtg/include/DuelLayers.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _DUELLAYERS_H_
|
||||
#define _DUELLAYERS_H_
|
||||
|
||||
|
||||
#include "GuiLayers.h"
|
||||
|
||||
class MTGGuiHand;
|
||||
class MTGGuiPlay;
|
||||
class ActionLayer;
|
||||
class ActionStack;
|
||||
class DamageResolverLayer;
|
||||
|
||||
class DuelLayers: public GuiLayers{
|
||||
|
||||
public:
|
||||
ActionLayer * actionLayer();
|
||||
MTGGuiHand * handLayer();
|
||||
MTGGuiPlay * playLayer();
|
||||
ActionStack * stackLayer();
|
||||
DamageResolverLayer * combatLayer();
|
||||
void init();
|
||||
|
||||
};
|
||||
|
||||
#include "ActionLayer.h"
|
||||
#include "GameObserver.h"
|
||||
#include "MTGGamePhase.h"
|
||||
#include "MTGGuiHand.h"
|
||||
#include "MTGGuiPlay.h"
|
||||
#include "ActionStack.h"
|
||||
#include "Damage.h"
|
||||
|
||||
|
||||
#endif
|
||||
88
projects/mtg/include/GameApp.h
Normal file
88
projects/mtg/include/GameApp.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Wagic, The Homebrew ?! is licensed under the BSD license
|
||||
* See LICENSE in the Folder's root
|
||||
* http://wololo.net/wagic/
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef _GAMEAPP_H_
|
||||
#define _GAMEAPP_H_
|
||||
|
||||
|
||||
#include "../include/Logger.h"
|
||||
|
||||
|
||||
#include <JApp.h>
|
||||
#include <JGE.h>
|
||||
#include <JSprite.h>
|
||||
#include <JLBFont.h>
|
||||
#include <hge/hgeparticle.h>
|
||||
|
||||
|
||||
#include <JResourceManager.h>
|
||||
|
||||
|
||||
#include "../include/GameState.h"
|
||||
|
||||
#include "../include/MTGDeck.h"
|
||||
#include "../include/MTGCard.h"
|
||||
#include "../include/MTGGameZones.h"
|
||||
|
||||
#include "../include/TexturesCache.h"
|
||||
|
||||
#define MAX_STATE 6
|
||||
|
||||
|
||||
#define PLAYER_TYPE_CPU 0
|
||||
#define PLAYER_TYPE_HUMAN 1
|
||||
#define PLAYER_TYPE_TESTSUITE 2
|
||||
|
||||
|
||||
class MTGAllCards;
|
||||
class TexturesCache;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class GameApp: public JApp
|
||||
{
|
||||
|
||||
private:
|
||||
bool mShowDebugInfo;
|
||||
int mScreenShotCount;
|
||||
|
||||
GameState* mCurrentState;
|
||||
GameState* mNextState;
|
||||
GameState* mGameStates[MAX_STATE];
|
||||
|
||||
|
||||
public:
|
||||
int players[2];
|
||||
MTGAllCards * collection;
|
||||
TexturesCache * cache;
|
||||
|
||||
GameApp();
|
||||
virtual ~GameApp();
|
||||
|
||||
virtual void Create();
|
||||
virtual void Destroy();
|
||||
virtual void Update();
|
||||
virtual void Render();
|
||||
virtual void Pause();
|
||||
virtual void Resume();
|
||||
|
||||
void LoadGameStates();
|
||||
void SetNextState(int state);
|
||||
static JResourceManager * CommonRes;
|
||||
static hgeParticleSystem * Particles[6];
|
||||
static int HasMusic;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
89
projects/mtg/include/GameObserver.h
Normal file
89
projects/mtg/include/GameObserver.h
Normal file
@@ -0,0 +1,89 @@
|
||||
#ifndef _GAMEOBSERVER_H_
|
||||
#define _GAMEOBSERVER_H_
|
||||
|
||||
#include "Player.h"
|
||||
#include "MTGAbility.h"
|
||||
#include "DuelLayers.h"
|
||||
#include "MTGCardInstance.h"
|
||||
#include "PlayGuiObject.h"
|
||||
#include "DuelLayers.h"
|
||||
#include "TargetChooser.h"
|
||||
|
||||
#define MAX_GAME_OBSERVERS 500
|
||||
|
||||
|
||||
class MTGGamePhase;
|
||||
class MTGAbility;
|
||||
class MTGCardInstance;
|
||||
class CardGui;
|
||||
class Player;
|
||||
class TargetChooser;
|
||||
|
||||
|
||||
class GameObserver{
|
||||
protected:
|
||||
int reaction;
|
||||
static GameObserver * mInstance;
|
||||
MTGCardInstance * cardWaitingForTargets;
|
||||
|
||||
int nbPlayers;
|
||||
int currentPlayerId;
|
||||
int currentRound;
|
||||
|
||||
|
||||
int targetListIsSet(MTGCardInstance * card);
|
||||
public:
|
||||
int cancelCurrentAction();
|
||||
int currentGamePhase;
|
||||
int oldGamePhase;
|
||||
TargetChooser * targetChooser;
|
||||
DuelLayers * mLayers;
|
||||
Player * gameOver;
|
||||
Player * players[2]; //created outside
|
||||
MTGGamePhase * gamePhaseManager; //Created Outside ?
|
||||
|
||||
TargetChooser * getCurrentTargetChooser();
|
||||
void stackObjectClicked(Interruptible * action);
|
||||
|
||||
void cardClick(MTGCardInstance * card,Targetable * _object = NULL );
|
||||
int enteringPhase(int phase);
|
||||
int getCurrentGamePhase();
|
||||
void userRequestNextGamePhase();
|
||||
void nextGamePhase();
|
||||
void cleanupPhase();
|
||||
void nextPlayer();
|
||||
static void Init(Player * _players[], int _nbplayers);
|
||||
static GameObserver * GetInstance();
|
||||
static void EndInstance();
|
||||
Player * currentPlayer;
|
||||
Player * currentActionPlayer;
|
||||
Player * isInterrupting;
|
||||
Player * opponent();
|
||||
Player * currentlyActing();
|
||||
GameObserver(Player * _players[], int _nbplayers);
|
||||
~GameObserver();
|
||||
void setGamePhaseManager(MTGGamePhase * _phases);
|
||||
void stateEffects();
|
||||
void eventOccured();
|
||||
void addObserver(MTGAbility * observer);
|
||||
void removeObserver(ActionElement * observer);
|
||||
void startGame(int shuffle = 1, int draw = 1);
|
||||
void nextStep();
|
||||
void untapPhase();
|
||||
void draw();
|
||||
int canPutInPlay(MTGCardInstance * card);
|
||||
void putInPlay(MTGCardInstance * card);
|
||||
int isInPlay(MTGCardInstance * card);
|
||||
int isACreature(MTGCardInstance * card);
|
||||
int tryToTapOrUntap(MTGCardInstance * card);
|
||||
|
||||
int checkManaCost(MTGCardInstance * card);
|
||||
|
||||
void Update(float dt);
|
||||
void Render();
|
||||
void ButtonPressed(int, PlayGuiObject*);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
24
projects/mtg/include/GameOptions.h
Normal file
24
projects/mtg/include/GameOptions.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _GAME_OPTIONS_H_
|
||||
#define _GAME_OPTIONS_H_
|
||||
|
||||
|
||||
#define MAX_OPTIONS 50
|
||||
#define OPTIONS_MUSICVOLUME 0
|
||||
#define OPTIONS_INTERRUPTATENDOFPHASE_OFFSET 1
|
||||
#define OPTIONS_SAVEFILE "Res/settings/options.txt"
|
||||
class GameOptions {
|
||||
public:
|
||||
int values[MAX_OPTIONS];
|
||||
static GameOptions * GetInstance();
|
||||
static void Destroy();
|
||||
int save();
|
||||
int load();
|
||||
|
||||
private:
|
||||
GameOptions();
|
||||
~GameOptions();
|
||||
static GameOptions* mInstance;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
46
projects/mtg/include/GameState.h
Normal file
46
projects/mtg/include/GameState.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef _GAME_STATE_H_
|
||||
#define _GAME_STATE_H_
|
||||
|
||||
#define FADING_SPEED 350.0f
|
||||
|
||||
class JGE;
|
||||
|
||||
#include <JSoundSystem.h>
|
||||
|
||||
enum _gameSates
|
||||
{
|
||||
GAME_STATE_MENU,
|
||||
GAME_STATE_DUEL,
|
||||
GAME_STATE_DECK_VIEWER,
|
||||
GAME_STATE_SHOP,
|
||||
GAME_STATE_OPTIONS
|
||||
};
|
||||
|
||||
|
||||
class GameApp;
|
||||
|
||||
class GameState
|
||||
{
|
||||
protected:
|
||||
GameApp* mParent;
|
||||
JGE* mEngine;
|
||||
|
||||
public:
|
||||
|
||||
static const char * const menuTexts[];
|
||||
GameState(GameApp* parent);
|
||||
virtual ~GameState() {}
|
||||
|
||||
virtual void Create() {}
|
||||
virtual void Destroy() {}
|
||||
|
||||
virtual void Start() {}
|
||||
virtual void End() {}
|
||||
|
||||
virtual void Update(float dt) = 0;
|
||||
virtual void Render() = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
790
projects/mtg/include/GameStateDeckViewer.h
Normal file
790
projects/mtg/include/GameStateDeckViewer.h
Normal file
@@ -0,0 +1,790 @@
|
||||
#ifndef _GAME_STATE_DECK_VIEWER_H_
|
||||
#define _GAME_STATE_DECK_VIEWER_H_
|
||||
|
||||
#include <math.h>
|
||||
#include <iostream>
|
||||
|
||||
#include <JGE.h>
|
||||
|
||||
#include "GameState.h"
|
||||
#include "SimpleMenu.h"
|
||||
#include "../include/CardGui.h"
|
||||
#include "../include/GameOptions.h"
|
||||
#include "../include/PriceList.h"
|
||||
#include "../include/PlayerData.h"
|
||||
#include "../include/DeckDataWrapper.h"
|
||||
|
||||
#define NO_USER_ACTIVITY_HELP_DELAY 10
|
||||
#define NO_USER_ACTIVITY_SHOWCARD_DELAY 0.1
|
||||
|
||||
#define STAGE_WAITING 2
|
||||
#define STAGE_TRANSITION_LEFT 1
|
||||
#define STAGE_TRANSITION_RIGHT 0
|
||||
#define STAGE_TRANSITION_UP 3
|
||||
#define STAGE_TRANSITION_DOWN 4
|
||||
#define STAGE_ONSCREEN_MENU 5
|
||||
#define STAGE_WELCOME 6
|
||||
#define STAGE_MENU 7
|
||||
|
||||
|
||||
#define ALL_COLORS -1
|
||||
|
||||
#define ROTATE_LEFT 1;
|
||||
#define ROTATE_RIGHT 0;
|
||||
|
||||
|
||||
|
||||
|
||||
class GameStateDeckViewer: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
JQuad * mIcons[7];
|
||||
JQuad * pspIcons[8];
|
||||
JTexture * pspIconsTexture;
|
||||
float last_user_activity;
|
||||
float onScreenTransition;
|
||||
float mRotation;
|
||||
float mSlide;
|
||||
int mAlpha;
|
||||
int mStage;
|
||||
|
||||
int colorFilter;
|
||||
JMusic * bgMusic;
|
||||
JTexture * backTex;
|
||||
JQuad * backQuad;
|
||||
SimpleMenu * welcome_menu;
|
||||
JLBFont * mFont;
|
||||
bool showing_user_deck;
|
||||
JLBFont * menuFont;
|
||||
SimpleMenu * menu;
|
||||
SimpleMenu * sellMenu;
|
||||
PriceList* pricelist;
|
||||
PlayerData * playerdata;
|
||||
int price;
|
||||
DeckDataWrapper * displayed_deck;
|
||||
DeckDataWrapper * myDeck;
|
||||
DeckDataWrapper * myCollection;
|
||||
MTGCard * currentCard;
|
||||
MTGCard * cardIndex[7];
|
||||
int hudAlpha;
|
||||
public:
|
||||
|
||||
GameStateDeckViewer(GameApp* parent): GameState(parent) {
|
||||
bgMusic = NULL;
|
||||
}
|
||||
virtual ~GameStateDeckViewer() {
|
||||
SAFE_DELETE(bgMusic);
|
||||
}
|
||||
|
||||
|
||||
void rotateCards(int direction){
|
||||
int maxCards=displayed_deck->getCount(colorFilter);
|
||||
if (maxCards==0)
|
||||
return;
|
||||
int left = direction;
|
||||
if (left){
|
||||
MTGCard * currentCard = displayed_deck->getNext(cardIndex[6],colorFilter);
|
||||
for (int i = 1; i<7; i++){
|
||||
cardIndex[i-1] = cardIndex[i];
|
||||
}
|
||||
cardIndex[6] = currentCard;
|
||||
}else{
|
||||
MTGCard * currentCard = displayed_deck->getPrevious(cardIndex[0],colorFilter);
|
||||
for (int i = 5; i>=0; i--){
|
||||
cardIndex[i+1] = cardIndex[i];
|
||||
}
|
||||
cardIndex[0] = currentCard;
|
||||
}
|
||||
displayed_deck->updateCurrentPosition(cardIndex[2],colorFilter);
|
||||
}
|
||||
|
||||
void loadIndexes(MTGCard * current = NULL){
|
||||
for (int i = 0; i < 7; i++){
|
||||
cardIndex[i] = NULL;
|
||||
}
|
||||
MTGCard * _current = current;
|
||||
_current = displayed_deck->getNext(NULL,colorFilter);
|
||||
for (int i = 0; i < 7; i++){
|
||||
cardIndex[i] = _current;
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf,"Loadindexes[%i] is NULL\n", i);
|
||||
if(_current) sprintf(buf, "LoadIndexes[%i] : %s\n", i, _current->getName());
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
_current = displayed_deck->getNext(_current,colorFilter);
|
||||
|
||||
}
|
||||
displayed_deck->updateCurrentPosition(cardIndex[2],colorFilter);
|
||||
}
|
||||
|
||||
void switchDisplay(){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("Switching display");
|
||||
#endif
|
||||
if (displayed_deck == myCollection){
|
||||
displayed_deck = myDeck;
|
||||
}else{
|
||||
displayed_deck = myCollection;
|
||||
}
|
||||
currentCard = NULL;
|
||||
loadIndexes();
|
||||
}
|
||||
|
||||
virtual void Start()
|
||||
{
|
||||
hudAlpha = 0;
|
||||
pricelist = NEW PriceList("Res/settings/prices.dat",mParent->collection);
|
||||
playerdata = NEW PlayerData(mParent->collection);
|
||||
sellMenu = NULL;
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck("Res/player/collection.dat", mParent->cache,mParent->collection));
|
||||
displayed_deck = myCollection;
|
||||
myDeck = NULL;
|
||||
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
mFont = GameApp::CommonRes->GetJLBFont("graphics/magic");
|
||||
|
||||
|
||||
|
||||
|
||||
menu = NEW SimpleMenu(11,this,menuFont,SCREEN_WIDTH/2-100,20,200);
|
||||
menu->Add(11,"Save");
|
||||
menu->Add(12,"Back to main menu");
|
||||
menu->Add(13, "Cancel");
|
||||
|
||||
|
||||
//icon images
|
||||
mIcons[MTG_COLOR_ARTIFACT] = GameApp::CommonRes->GetQuad("c_artifact");
|
||||
mIcons[MTG_COLOR_LAND] = GameApp::CommonRes->GetQuad("c_land");
|
||||
mIcons[MTG_COLOR_WHITE] = GameApp::CommonRes->GetQuad("c_white");
|
||||
mIcons[MTG_COLOR_RED] = GameApp::CommonRes->GetQuad("c_red");
|
||||
mIcons[MTG_COLOR_BLACK] = GameApp::CommonRes->GetQuad("c_black");
|
||||
mIcons[MTG_COLOR_BLUE] = GameApp::CommonRes->GetQuad("c_blue");
|
||||
mIcons[MTG_COLOR_GREEN] = GameApp::CommonRes->GetQuad("c_green");
|
||||
for (int i=0; i < 7; i++){
|
||||
mIcons[i]->SetHotSpot(16,16);
|
||||
}
|
||||
|
||||
|
||||
pspIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/iconspsp.png", TEX_TYPE_USE_VRAM);
|
||||
|
||||
for (int i=0; i < 8; i++){
|
||||
pspIcons[i] = NEW JQuad(pspIconsTexture, i*32, 0, 32, 32);
|
||||
pspIcons[i]->SetHotSpot(16,16);
|
||||
}
|
||||
|
||||
|
||||
backTex = JRenderer::GetInstance()->LoadTexture("sets/back.jpg", TEX_TYPE_USE_VRAM);
|
||||
backQuad = NEW JQuad(backTex, 0, 0, 200, 285); // Create quad for rendering.
|
||||
|
||||
//menuFont = NEW JLBFont("graphics/f3",16);
|
||||
menuFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
welcome_menu = NEW SimpleMenu(10,this,menuFont,20,20,200);
|
||||
char buffer[100];
|
||||
for (int i=1; i < 6; i++){
|
||||
sprintf(buffer, "Res/player/deck%i.txt",i);
|
||||
std::ifstream file(buffer);
|
||||
if(file){
|
||||
welcome_menu->Add(i, GameState::menuTexts[i]);
|
||||
file.close();
|
||||
}else{
|
||||
welcome_menu->Add(i, GameState::menuTexts[0]);
|
||||
}
|
||||
|
||||
}
|
||||
welcome_menu->Add(10, "Cancel");
|
||||
|
||||
if (GameApp::HasMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
|
||||
if (!bgMusic) bgMusic = JSoundSystem::GetInstance()->LoadMusic("sound/track1.mp3");
|
||||
if (bgMusic){
|
||||
JSoundSystem::GetInstance()->PlayMusic(bgMusic, true);
|
||||
}
|
||||
}
|
||||
colorFilter = ALL_COLORS;
|
||||
|
||||
mStage = STAGE_WELCOME;
|
||||
|
||||
mRotation = 0;
|
||||
mSlide = 0;
|
||||
mAlpha = 255;
|
||||
//mEngine->ResetPrivateVRAM();
|
||||
//mEngine->EnableVSync(true);
|
||||
currentCard = NULL;
|
||||
loadIndexes(currentCard);
|
||||
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
||||
onScreenTransition = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void End()
|
||||
{
|
||||
//mEngine->EnableVSync(false);
|
||||
if (bgMusic) JSoundSystem::GetInstance()->StopMusic(bgMusic);
|
||||
SAFE_DELETE(backTex);
|
||||
SAFE_DELETE(backQuad);
|
||||
SAFE_DELETE(welcome_menu);
|
||||
SAFE_DELETE(menu);
|
||||
SAFE_DELETE(pspIconsTexture);
|
||||
for (int i=0; i < 8; i++){
|
||||
delete pspIcons[i];
|
||||
}
|
||||
SAFE_DELETE(myCollection);
|
||||
SAFE_DELETE(myDeck);
|
||||
SAFE_DELETE(pricelist);
|
||||
SAFE_DELETE(playerdata);
|
||||
}
|
||||
|
||||
|
||||
void addRemove(MTGCard * card){
|
||||
if (!card) return;
|
||||
if (displayed_deck->Remove(card)){
|
||||
if (displayed_deck == myCollection){
|
||||
myDeck->Add(card);
|
||||
}else{
|
||||
myCollection->Add(card);
|
||||
}
|
||||
}
|
||||
//loadIndexes(cardIndex[0]);
|
||||
}
|
||||
|
||||
int Remove(MTGCard * card){
|
||||
if (!card) return 0;
|
||||
int result = displayed_deck->Remove(card);
|
||||
loadIndexes(currentCard);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
virtual void Update(float dt)
|
||||
{
|
||||
|
||||
hudAlpha = 255-(last_user_activity * 500);
|
||||
if (hudAlpha < 0) hudAlpha = 0;
|
||||
if (sellMenu){
|
||||
sellMenu->Update(dt);
|
||||
return;
|
||||
}
|
||||
if (mStage == STAGE_WAITING || mStage == STAGE_ONSCREEN_MENU){
|
||||
if (mEngine->GetButtonState(PSP_CTRL_LEFT)){
|
||||
last_user_activity = 0;
|
||||
currentCard = displayed_deck->getNext(currentCard,colorFilter);
|
||||
mStage = STAGE_TRANSITION_LEFT;
|
||||
}
|
||||
|
||||
else if (mEngine->GetButtonState(PSP_CTRL_RIGHT))
|
||||
{
|
||||
last_user_activity = 0;
|
||||
currentCard = displayed_deck->getPrevious(currentCard,colorFilter);
|
||||
mStage = STAGE_TRANSITION_RIGHT;
|
||||
}
|
||||
else if (mEngine->GetButtonState(PSP_CTRL_UP))
|
||||
{
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_TRANSITION_UP;
|
||||
colorFilter --;
|
||||
if (colorFilter < -1) colorFilter = MTG_COLOR_LAND;
|
||||
}
|
||||
|
||||
else if (mEngine->GetButtonState(PSP_CTRL_DOWN))
|
||||
{
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_TRANSITION_DOWN;
|
||||
colorFilter ++;
|
||||
if (colorFilter > MTG_COLOR_LAND) colorFilter =-1;
|
||||
|
||||
}
|
||||
else if (mEngine->GetButtonClick(PSP_CTRL_TRIANGLE) && last_user_activity > 0.2)
|
||||
|
||||
{
|
||||
last_user_activity = 0;
|
||||
switchDisplay();
|
||||
|
||||
}
|
||||
else if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE))
|
||||
{
|
||||
last_user_activity = 0;
|
||||
addRemove(cardIndex[2]);
|
||||
|
||||
}
|
||||
else if (mEngine->GetButtonClick(PSP_CTRL_CROSS))
|
||||
{
|
||||
last_user_activity = 0;
|
||||
SAFE_DELETE(sellMenu);
|
||||
char buffer[4096];
|
||||
MTGCard * card = cardIndex[2];
|
||||
if (card){
|
||||
int rnd = (rand() % 20);
|
||||
price = pricelist->getPrice(card->getMTGId()) / 2;
|
||||
price = price - price * (rnd -10)/100;
|
||||
sprintf(buffer,"%s : %i credits",card->getName(),price);
|
||||
sellMenu = NEW SimpleMenu(2,this,mFont,SCREEN_WIDTH-300,SCREEN_HEIGHT/2,270,buffer);
|
||||
sellMenu->Add(20,"Yes");
|
||||
sellMenu->Add(21,"No");
|
||||
}
|
||||
|
||||
}
|
||||
else if (mEngine->GetButtonClick(PSP_CTRL_SQUARE))
|
||||
{
|
||||
if (last_user_activity < NO_USER_ACTIVITY_HELP_DELAY){
|
||||
last_user_activity = NO_USER_ACTIVITY_HELP_DELAY + 1;
|
||||
}else{
|
||||
last_user_activity = 0;
|
||||
mStage = STAGE_WAITING;
|
||||
}
|
||||
|
||||
}
|
||||
else if (mEngine->GetButtonClick(PSP_CTRL_START))
|
||||
{
|
||||
mStage = STAGE_MENU;
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
if (last_user_activity > NO_USER_ACTIVITY_HELP_DELAY){
|
||||
if (mStage != STAGE_ONSCREEN_MENU){
|
||||
mStage = STAGE_ONSCREEN_MENU;
|
||||
onScreenTransition = 1;
|
||||
}else{
|
||||
if (onScreenTransition >0){
|
||||
onScreenTransition-= 0.05f;
|
||||
}else{
|
||||
onScreenTransition = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
last_user_activity+= dt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}else if (mStage == STAGE_TRANSITION_RIGHT || mStage == STAGE_TRANSITION_LEFT) {
|
||||
//mAlpha = 128;
|
||||
if (mStage == STAGE_TRANSITION_RIGHT){
|
||||
mRotation -= 0.05f;
|
||||
}else if(mStage == STAGE_TRANSITION_LEFT){
|
||||
mRotation += 0.05f;
|
||||
}
|
||||
if (fabs(mRotation) > 1.0f){
|
||||
rotateCards(mStage);
|
||||
mRotation = 0;
|
||||
mStage = STAGE_WAITING;
|
||||
}
|
||||
}else if (mStage == STAGE_TRANSITION_DOWN || mStage == STAGE_TRANSITION_UP){
|
||||
if (mStage == STAGE_TRANSITION_DOWN){
|
||||
mSlide -= 0.05f;
|
||||
if (mSlide < -1.0f){
|
||||
loadIndexes(currentCard);
|
||||
mSlide = 1;
|
||||
}else if (mSlide > 0 && mSlide < 0.05){
|
||||
mStage = STAGE_WAITING;
|
||||
mSlide = 0;
|
||||
}
|
||||
}else if (mStage == STAGE_TRANSITION_UP){
|
||||
mSlide += 0.05f;
|
||||
if (mSlide > 1.0f){
|
||||
loadIndexes(currentCard);
|
||||
mSlide = -1;
|
||||
}else if (mSlide < 0 && mSlide > -0.05){
|
||||
mStage = STAGE_WAITING;
|
||||
mSlide = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}else if (mStage == STAGE_WELCOME){
|
||||
welcome_menu->Update(dt);
|
||||
}else if (mStage == STAGE_MENU){
|
||||
menu->Update(dt);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void renderOnScreenBasicInfo(){
|
||||
char buffer[30], buffer2[30];
|
||||
|
||||
float y = 0;
|
||||
JRenderer::GetInstance()->FillRoundRect(SCREEN_WIDTH-125,y-5,110,15,5,ARGB(128,0,0,0));
|
||||
sprintf(buffer, "DECK: %i", myDeck->getCount());
|
||||
mFont->DrawString(buffer, SCREEN_WIDTH-120 , y);
|
||||
|
||||
if (colorFilter != ALL_COLORS){
|
||||
sprintf(buffer2, "( %i)", myDeck->getCount(colorFilter));
|
||||
mFont->DrawString(buffer2, SCREEN_WIDTH-55 , y);
|
||||
JRenderer::GetInstance()->RenderQuad(mIcons[colorFilter], SCREEN_WIDTH-42 , y + 6 , 0.0f,0.5,0.5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void renderSlideBar(){
|
||||
int currentPos = displayed_deck->currentposition;
|
||||
int total = displayed_deck->getCount(colorFilter);
|
||||
int filler = 15;
|
||||
int y = SCREEN_HEIGHT-25;
|
||||
int bar_size = SCREEN_WIDTH - 2*filler;
|
||||
int cursor_pos = bar_size * currentPos / total;
|
||||
JRenderer * r = JRenderer::GetInstance();
|
||||
r->FillRoundRect(filler + 5,y+5,bar_size,0,3,ARGB(hudAlpha/2,0,0,0));
|
||||
r->DrawLine(filler+cursor_pos + 5 ,y+5,filler+cursor_pos + 5,y+10,ARGB(hudAlpha/2,0,0,0));
|
||||
|
||||
r->FillRoundRect(filler,y,bar_size,0,3,ARGB(hudAlpha/2,128,128,128));
|
||||
//r->FillCircle(filler+cursor_pos + 3 ,SCREEN_HEIGHT - 15 + 3,6,ARGB(255,128,128,128));
|
||||
r->DrawLine(filler+cursor_pos,y,filler+cursor_pos,y+5,ARGB(hudAlpha,255,255,255));
|
||||
char buffer[256];
|
||||
string deckname = "Collection";
|
||||
if (displayed_deck == myDeck){
|
||||
deckname = "Deck";
|
||||
}
|
||||
sprintf(buffer,"%s - %i/%i", deckname.c_str(),currentPos, total);
|
||||
mFont->SetColor(ARGB(hudAlpha,255,255,255));
|
||||
mFont->DrawString(buffer,SCREEN_WIDTH/2, y+5,JGETEXT_CENTER);
|
||||
|
||||
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
}
|
||||
|
||||
void renderDeckBackground(){
|
||||
int max1 = 0;
|
||||
int maxC1 = 4;
|
||||
int max2 = 0;
|
||||
int maxC2 = 4;
|
||||
|
||||
for (int i= 0; i< MTG_NB_COLORS -1; i++){
|
||||
int value = myDeck->getCount(i);
|
||||
if (value > max1){
|
||||
max2 = max1;
|
||||
maxC2 = maxC1;
|
||||
max1 = value;
|
||||
maxC1 = i;
|
||||
}else if (value > max2){
|
||||
max2 = value;
|
||||
maxC2 = i;
|
||||
}
|
||||
}
|
||||
if (max2 < max1/2){
|
||||
maxC2 = maxC1;
|
||||
}
|
||||
|
||||
int _a[6] = {255, 255, 255,255,255,255};
|
||||
int _r[6] = {75, 0, 0, 255,50,255};
|
||||
int _g[6] = {30, 255, 0, 0, 50,255};
|
||||
int _b[6] = {20, 0, 255,0, 50,255};
|
||||
|
||||
|
||||
PIXEL_TYPE colors[] =
|
||||
{
|
||||
ARGB(255,_r[maxC1],_g[maxC1],_b[maxC1]),
|
||||
ARGB(255,_r[maxC1],_g[maxC1],_b[maxC1]),
|
||||
ARGB(255,_r[maxC2],_g[maxC2],_b[maxC2]),
|
||||
ARGB(255,_r[maxC2],_g[maxC2],_b[maxC2]),
|
||||
};
|
||||
|
||||
JRenderer::GetInstance()->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,colors);
|
||||
|
||||
}
|
||||
|
||||
void renderOnScreenMenu(){
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
JRenderer * r = JRenderer::GetInstance();
|
||||
float pspIconsSize = 0.5;
|
||||
|
||||
float leftTransition = onScreenTransition*84;
|
||||
float rightTransition = onScreenTransition*204;
|
||||
float leftPspX = 40 - leftTransition;
|
||||
float leftPspY = SCREEN_HEIGHT/2 - 30 ;
|
||||
float rightPspX = SCREEN_WIDTH-100 + rightTransition;
|
||||
float rightPspY = SCREEN_HEIGHT/2 - 30 ;
|
||||
|
||||
|
||||
//FillRects
|
||||
r->FillRect(0-(onScreenTransition*84),0,84,SCREEN_HEIGHT,ARGB(128,0,0,0));
|
||||
r->FillRect(SCREEN_WIDTH-204+(onScreenTransition*204),0,200,SCREEN_HEIGHT,ARGB(128,0,0,0));
|
||||
|
||||
|
||||
//LEFT PSP CIRCLE render
|
||||
r->FillCircle(leftPspX,leftPspY,40,ARGB(128,50,50,50));
|
||||
|
||||
r->RenderQuad(pspIcons[0],leftPspX, leftPspY - 20,0,pspIconsSize,pspIconsSize);
|
||||
r->RenderQuad(pspIcons[1],leftPspX, leftPspY + 20,0,pspIconsSize,pspIconsSize);
|
||||
r->RenderQuad(pspIcons[2],leftPspX - 20, leftPspY,0,pspIconsSize,pspIconsSize);
|
||||
r->RenderQuad(pspIcons[3],leftPspX + 20, leftPspY,0,pspIconsSize,pspIconsSize);
|
||||
|
||||
|
||||
mFont->DrawString("Prev.", leftPspX - 35, leftPspY-15);
|
||||
mFont->DrawString("Next", leftPspX + 15, leftPspY-15);
|
||||
mFont->DrawString("card", leftPspX - 35, leftPspY);
|
||||
mFont->DrawString("card", leftPspX + 15, leftPspY);
|
||||
mFont->DrawString("Next color", leftPspX - 33, leftPspY - 35);
|
||||
mFont->DrawString("Prev. color", leftPspX -33 , leftPspY +25);
|
||||
|
||||
//RIGHT PSP CIRCLE render
|
||||
r->FillCircle(rightPspX+(onScreenTransition*204),rightPspY,40,ARGB(128,50,50,50));
|
||||
r->RenderQuad(pspIcons[4],rightPspX+20, rightPspY,0,pspIconsSize,pspIconsSize);
|
||||
r->RenderQuad(pspIcons[5],rightPspX, rightPspY - 20,0,pspIconsSize,pspIconsSize);
|
||||
r->RenderQuad(pspIcons[6],rightPspX-20, rightPspY,0,pspIconsSize,pspIconsSize);
|
||||
r->RenderQuad(pspIcons[7],rightPspX, rightPspY + 20,0,pspIconsSize,pspIconsSize);
|
||||
|
||||
if (displayed_deck == myCollection){
|
||||
mFont->DrawString("Add card", rightPspX + 20, rightPspY-15);
|
||||
mFont->DrawString("Display Deck", rightPspX - 35, rightPspY - 40);
|
||||
}else{
|
||||
mFont->DrawString("Remove card", rightPspX + 20, rightPspY-15);
|
||||
mFont->DrawString("Display Collection", rightPspX - 35, rightPspY - 40);
|
||||
}
|
||||
mFont->DrawString("Deck info", rightPspX - 70 , rightPspY-15);
|
||||
mFont->DrawString("Sell card", rightPspX - 30 , rightPspY+20);
|
||||
//Bottom menus
|
||||
mFont->DrawString("menu", SCREEN_WIDTH-35 +rightTransition, SCREEN_HEIGHT-15);
|
||||
|
||||
|
||||
|
||||
//Your Deck Information
|
||||
char buffer[300];
|
||||
int nb_letters = 0;
|
||||
for (int j=0; j<MTG_NB_COLORS;j++){
|
||||
int value = myDeck->getCount(j);
|
||||
if (value > 0){
|
||||
sprintf(buffer, "%i", value);
|
||||
mFont->DrawString(buffer, SCREEN_WIDTH-190+rightTransition + nb_letters*13, SCREEN_HEIGHT/2 + 40);
|
||||
r->RenderQuad(mIcons[j],SCREEN_WIDTH-197+rightTransition + nb_letters*13 , SCREEN_HEIGHT/2 + 46,0,0.5,0.5);
|
||||
if (value > 9){nb_letters += 3;}else{nb_letters+=2;}
|
||||
}
|
||||
}
|
||||
int value = myDeck->getCount();
|
||||
sprintf(buffer, "Your Deck: %i cards", value);
|
||||
mFont->DrawString(buffer, SCREEN_WIDTH-200+rightTransition, SCREEN_HEIGHT/2 + 25);
|
||||
|
||||
//TODO, put back !
|
||||
/*int nbCreatures = myDeck->countByType("Creature");
|
||||
int nbSpells = myDeck->countByType("Instant") + myDeck->countByType("Enchantment") + myDeck->countByType("Sorcery");
|
||||
|
||||
sprintf(buffer, "Creatures: %i - Spells: %i", nbCreatures, nbSpells);
|
||||
mFont->DrawString(buffer, SCREEN_WIDTH-200+rightTransition, SCREEN_HEIGHT/2 + 55);
|
||||
*/
|
||||
|
||||
|
||||
mFont->DrawString("You are currently viewing your", SCREEN_WIDTH-200+rightTransition, 5);
|
||||
if (displayed_deck == myCollection){
|
||||
mFont->DrawString("collection. Press TRIANGLE", SCREEN_WIDTH-200+rightTransition, 20);
|
||||
mFont->DrawString("to switch to your deck", SCREEN_WIDTH-200+rightTransition, 35);
|
||||
}else{
|
||||
mFont->DrawString("deck. Press TRIANGLE to", SCREEN_WIDTH-200+rightTransition, 20);
|
||||
mFont->DrawString("switch to your collection", SCREEN_WIDTH-200+rightTransition, 35);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void renderCard(int id, float rotation){
|
||||
MTGCard * card = cardIndex[id];
|
||||
|
||||
|
||||
float max_scale = 0.96;
|
||||
float min_scale = 0.2;
|
||||
float x_center_0 = 180;
|
||||
float right_border = SCREEN_WIDTH - 20 ;
|
||||
|
||||
float x_center = x_center_0 + cos((rotation + 8 - id)*M_PI/12)*(right_border-x_center_0);
|
||||
float scale = max_scale/ 1.12 * cos((x_center-x_center_0)*1.5/(right_border - x_center_0) ) + 0.2 * max_scale * cos (cos((x_center-x_center_0)*0.15/(right_border - x_center_0) ));
|
||||
float x = x_center - 100*scale;
|
||||
|
||||
float y = (SCREEN_HEIGHT - 285*scale)/2 + SCREEN_HEIGHT*mSlide*(scale+0.2);
|
||||
|
||||
int alpha = (int) (255 * (scale + 1.0 - max_scale));
|
||||
|
||||
if (!card){
|
||||
/*int scaleBackup = mFont->GetScale();
|
||||
mFont->SetScale(scale);
|
||||
mFont->DrawString("empty slot", x, y);
|
||||
mFont->SetScale(scaleBackup);*/
|
||||
return;
|
||||
}
|
||||
JQuad * quad = backQuad;
|
||||
|
||||
int showName = 1;
|
||||
if (mParent->cache->isInCache(card) || last_user_activity > (abs(2-id) + 1)* NO_USER_ACTIVITY_SHOWCARD_DELAY){
|
||||
quad = card->getQuad(mParent->cache);
|
||||
showName = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (quad){
|
||||
int quadAlpha = alpha;
|
||||
if ( !displayed_deck->cards[card]) quadAlpha /=2;
|
||||
quad->SetColor(ARGB(mAlpha,quadAlpha,quadAlpha,quadAlpha));
|
||||
JRenderer::GetInstance()->RenderQuad(quad, x , y , 0.0f,scale,scale);
|
||||
if (showName){
|
||||
char buffer[4096];
|
||||
sprintf(buffer, "%s", card->getName());
|
||||
int scaleBackup = mFont->GetScale();
|
||||
mFont->SetScale(1*scale);
|
||||
mFont->DrawString(buffer,x,y);
|
||||
mFont->SetScale(scaleBackup);
|
||||
}
|
||||
}else{
|
||||
CardGui::alternateRender(card, mFont, mIcons, x_center, y + 142.5*scale, 0, scale);
|
||||
}
|
||||
if (last_user_activity < 3){
|
||||
int fontAlpha = alpha;
|
||||
float qtY = y + 0 * scale;
|
||||
float qtX = x + 120*scale;
|
||||
char buffer[4096];
|
||||
sprintf(buffer, "x%i", displayed_deck->cards[card]);
|
||||
JLBFont * font = menuFont;
|
||||
int scaleBackup = font->GetScale();
|
||||
font->SetScale(1*scale);
|
||||
font->SetColor(ARGB(fontAlpha/2,0,0,0));
|
||||
JRenderer::GetInstance()->FillRect(qtX, qtY,32*scale,20*scale,ARGB(fontAlpha/2,0,0,0));
|
||||
font->DrawString(buffer, qtX + 2, qtY + 2);
|
||||
font->SetColor(ARGB(fontAlpha,255,255,255));
|
||||
font->DrawString(buffer, qtX, qtY);
|
||||
font->SetScale(scaleBackup);
|
||||
font->SetColor(ARGB(255,255,255,255));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void renderCard (int id){
|
||||
renderCard(id, 0);
|
||||
}
|
||||
|
||||
virtual void Render()
|
||||
{
|
||||
// void RenderQuad(JQuad* quad, float xo, float yo, float angle=0.0f, float xScale=1.0f, float yScale=1.0f);
|
||||
|
||||
JRenderer::GetInstance()->ClearScreen(ARGB(0,0,0,0));
|
||||
|
||||
|
||||
if(displayed_deck == myDeck){
|
||||
renderDeckBackground();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int order[3] = {1,2,3};
|
||||
if (mRotation < 0.5 && mRotation > -0.5){
|
||||
order[1]=3;
|
||||
order[2]=2;
|
||||
}else if (mRotation < -0.5){
|
||||
order[0] = 3;
|
||||
order[2] = 1;
|
||||
}
|
||||
|
||||
renderCard(6,mRotation);
|
||||
renderCard(5,mRotation);
|
||||
renderCard(4,mRotation);
|
||||
renderCard(0,mRotation);
|
||||
|
||||
for (int i =0; i< 3; i++){
|
||||
renderCard(order[i],mRotation);
|
||||
}
|
||||
|
||||
if (displayed_deck->getCount(colorFilter)>0){
|
||||
renderSlideBar();
|
||||
}else{
|
||||
int scaleBackup = mFont->GetScale();
|
||||
mFont->SetScale(2);
|
||||
mFont->DrawString("No Card", SCREEN_WIDTH/2, SCREEN_HEIGHT/2,JGETEXT_CENTER);
|
||||
mFont->SetScale(scaleBackup);
|
||||
}
|
||||
|
||||
if (mStage == STAGE_ONSCREEN_MENU){
|
||||
renderOnScreenMenu();
|
||||
}else if (mStage == STAGE_WELCOME){
|
||||
welcome_menu->Render();
|
||||
}else{
|
||||
renderOnScreenBasicInfo();
|
||||
if (sellMenu) sellMenu->Render();
|
||||
}
|
||||
if (mStage == STAGE_MENU){
|
||||
menu->Render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int loadDeck(int deckid){
|
||||
SAFE_DELETE(myCollection);
|
||||
myCollection = NEW DeckDataWrapper(NEW MTGDeck("Res/player/collection.dat", mParent->cache,mParent->collection));
|
||||
displayed_deck = myCollection;
|
||||
char filename[4096];
|
||||
sprintf(filename, "Res/player/deck%i.txt", deckid);
|
||||
SAFE_DELETE(myDeck);
|
||||
myDeck = NEW DeckDataWrapper(NEW MTGDeck(filename, mParent->cache,mParent->collection));
|
||||
MTGCard * current = myDeck->getNext();
|
||||
while (current){
|
||||
int howmanyinDeck = myDeck->cards[current];
|
||||
for (int i = 0; i < howmanyinDeck; i++){
|
||||
int deleted = myCollection->Remove(current);
|
||||
if (!deleted){
|
||||
myDeck->Remove(current);
|
||||
}
|
||||
}
|
||||
current = myDeck->getNext(current);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual void ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
switch (controlId)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
loadDeck(controlId);
|
||||
mStage = STAGE_WAITING;
|
||||
break;
|
||||
case 10:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
break;
|
||||
case 11:
|
||||
myDeck->save();
|
||||
playerdata->save();
|
||||
pricelist->save();
|
||||
mStage = STAGE_WAITING;
|
||||
break;
|
||||
case 12:
|
||||
mParent->SetNextState(GAME_STATE_MENU);
|
||||
break;
|
||||
case 13:
|
||||
mStage = STAGE_WAITING;
|
||||
break;
|
||||
case 20:
|
||||
{
|
||||
MTGCard * card = cardIndex[2];
|
||||
if (card){
|
||||
int rnd = (rand() % 20);
|
||||
price = price - (rnd * price)/100;
|
||||
playerdata->credits += price;
|
||||
pricelist->setPrice(card->getMTGId(),price*2);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf, "CARD'S NAME : %s", card->getName());
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
playerdata->collection->remove(card->getMTGId());
|
||||
Remove(card);
|
||||
}
|
||||
}
|
||||
case 21:
|
||||
SAFE_DELETE(sellMenu);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
55
projects/mtg/include/GameStateDuel.h
Normal file
55
projects/mtg/include/GameStateDuel.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#ifndef _GAME_STATE_DUEL_H_
|
||||
#define _GAME_STATE_DUEL_H_
|
||||
|
||||
|
||||
#include "../include/GameState.h"
|
||||
#include "_includeAll.h"
|
||||
#include "../include/SimpleMenu.h"
|
||||
|
||||
|
||||
#define DUEL_START 0
|
||||
#define DUEL_END 1
|
||||
#define DUEL_CHOOSE_DECK1 2
|
||||
#define DUEL_CHOOSE_DECK2 3
|
||||
#define ERROR_NO_DECK 4
|
||||
#define DUEL_PLAY 5
|
||||
#define DUEL_MENU 6
|
||||
|
||||
|
||||
#ifdef TESTSUITE
|
||||
class TestSuite;
|
||||
#endif
|
||||
|
||||
class GameStateDuel: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
#ifdef TESTSUITE
|
||||
TestSuite * testSuite;
|
||||
#endif
|
||||
int mGamePhase;
|
||||
Player * mCurrentPlayer;
|
||||
Player * mPlayers[2];
|
||||
MTGPlayerCards * deck[2];
|
||||
GameObserver * game;
|
||||
SimpleMenu * deckmenu;
|
||||
SimpleMenu * menu;
|
||||
JLBFont* mFont;
|
||||
|
||||
void loadPlayer(int playerId, int decknb = 0);
|
||||
public:
|
||||
GameStateDuel(GameApp* parent);
|
||||
virtual ~GameStateDuel();
|
||||
#ifdef TESTSUITE
|
||||
void loadTestSuitePlayers();
|
||||
#endif
|
||||
virtual void ButtonPressed(int ControllerId, int ControlId);
|
||||
virtual void Start();
|
||||
virtual void End();
|
||||
virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
432
projects/mtg/include/GameStateMenu.h
Normal file
432
projects/mtg/include/GameStateMenu.h
Normal file
@@ -0,0 +1,432 @@
|
||||
#ifndef _GAME_STATE_MENU_H_
|
||||
#define _GAME_STATE_MENU_H_
|
||||
|
||||
#include <JGui.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include "GameState.h"
|
||||
#include "MenuItem.h"
|
||||
#include "SimpleMenu.h"
|
||||
|
||||
#include "../include/GameOptions.h"
|
||||
|
||||
|
||||
|
||||
#define STATE_MENU 0
|
||||
#define STATE_SUBMENU 1
|
||||
#define STATE_LOADING_MENU 2
|
||||
#define STATE_LOADING_CARDS 3
|
||||
#define STATE_FIRST_TIME 4
|
||||
#define STATE_WARNING 5
|
||||
|
||||
#define GAME_VERSION "WTH?! 0.2.1 - by WilLoW"
|
||||
#define ALPHA_WARNING 0
|
||||
|
||||
class GameStateMenu: public GameState, public JGuiListener
|
||||
|
||||
{
|
||||
private:
|
||||
JGuiController* mGuiController;
|
||||
SimpleMenu* subMenuController;
|
||||
JLBFont* mFont;
|
||||
JQuad * mIcons[10];
|
||||
JTexture * mIconsTexture;
|
||||
JTexture * bgTexture;
|
||||
JQuad * mBg;
|
||||
float mCreditsYPos;
|
||||
int currentState;
|
||||
JMusic * bgMusic;
|
||||
int mVolume;
|
||||
char nbcardsStr[400];
|
||||
|
||||
DIR *mDip;
|
||||
struct dirent *mDit;
|
||||
char mCurrentSetName[10];
|
||||
char mCurrentSetFileName[512];
|
||||
|
||||
int mReadConf;
|
||||
|
||||
|
||||
public:
|
||||
GameStateMenu(GameApp* parent): GameState(parent)
|
||||
{
|
||||
mGuiController = NULL;
|
||||
subMenuController = NULL;
|
||||
mIconsTexture = NULL;
|
||||
bgMusic = NULL;
|
||||
}
|
||||
|
||||
virtual ~GameStateMenu()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void Create()
|
||||
{
|
||||
|
||||
mDip = NULL;
|
||||
mReadConf = 0;
|
||||
mCurrentSetName[0] = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mIconsTexture = JRenderer::GetInstance()->LoadTexture("graphics/menuicons.png", TEX_TYPE_USE_VRAM);
|
||||
bgTexture = JRenderer::GetInstance()->LoadTexture("graphics/menutitle.png", TEX_TYPE_USE_VRAM);
|
||||
mBg = NEW JQuad(bgTexture, 10, 0, 220, 80); // Create background quad for rendering.
|
||||
mBg->SetHotSpot(105,32);
|
||||
//load all the icon images
|
||||
int n = 0;
|
||||
for (int i=0;i<5;i++)
|
||||
{
|
||||
for (int j=0;j<2;j++)
|
||||
{
|
||||
mIcons[n] = NEW JQuad(mIconsTexture, 10 + i*32, j*32, 32, 32);
|
||||
mIcons[n]->SetHotSpot(16,16);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
mFont = GameApp::CommonRes->GetJLBFont("graphics/f3");
|
||||
//mFont->SetBase(0); // using 2nd font
|
||||
mGuiController = NEW JGuiController(100, this);
|
||||
//mGuiController->SetShadingBackground(10, 45, 80, 100, ARGB(255,0,0,0));
|
||||
if (mGuiController)
|
||||
{
|
||||
mGuiController->Add(NEW MenuItem(1, mFont, "Play", 80, SCREEN_HEIGHT/2, mIcons[8], mIcons[9],"graphics/particle1.psi",GameApp::CommonRes->GetQuad("particles"), true));
|
||||
mGuiController->Add(NEW MenuItem(2, mFont, "Deck Editor", 160, SCREEN_HEIGHT/2, mIcons[2], mIcons[3],"graphics/particle2.psi",GameApp::CommonRes->GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(3, mFont, "Shop", 240, SCREEN_HEIGHT/2, mIcons[0], mIcons[1],"graphics/particle3.psi",GameApp::CommonRes->GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(4, mFont, "Options", 320, SCREEN_HEIGHT/2, mIcons[6], mIcons[7],"graphics/particle4.psi",GameApp::CommonRes->GetQuad("particles")));
|
||||
mGuiController->Add(NEW MenuItem(5, mFont, "Exit", 400, SCREEN_HEIGHT/2, mIcons[4], mIcons[5],"graphics/particle5.psi",GameApp::CommonRes->GetQuad("particles")));
|
||||
}
|
||||
|
||||
|
||||
currentState = STATE_LOADING_CARDS;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void Destroy()
|
||||
{
|
||||
if (mGuiController)
|
||||
delete mGuiController;
|
||||
|
||||
if (subMenuController)
|
||||
delete subMenuController;
|
||||
|
||||
if (mIconsTexture)
|
||||
delete mIconsTexture;
|
||||
|
||||
for (int i = 0; i < 10 ; i++){
|
||||
delete mIcons[i];
|
||||
}
|
||||
|
||||
if (mBg) delete mBg;
|
||||
|
||||
SAFE_DELETE (bgMusic);
|
||||
}
|
||||
|
||||
|
||||
virtual void Start(){
|
||||
JRenderer::GetInstance()->ResetPrivateVRAM();
|
||||
JRenderer::GetInstance()->EnableVSync(true);
|
||||
|
||||
if (GameApp::HasMusic && !bgMusic && GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME] > 0){
|
||||
bgMusic = JSoundSystem::GetInstance()->LoadMusic("sound/track0.mp3");
|
||||
}
|
||||
|
||||
if (bgMusic){
|
||||
mVolume = 0;
|
||||
JSoundSystem::GetInstance()->SetVolume(mVolume);
|
||||
JSoundSystem::GetInstance()->PlayMusic(bgMusic, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Retrieves the next set subfolder automatically
|
||||
*/
|
||||
int nextCardSet(){
|
||||
int found = 0;
|
||||
if (!mDip){
|
||||
mDip = opendir("Res/sets/");
|
||||
}
|
||||
|
||||
while (!found && (mDit = readdir(mDip))){
|
||||
sprintf(mCurrentSetFileName, "Res/sets/%s/_cards.dat", mDit->d_name);
|
||||
std::ifstream file(mCurrentSetFileName);
|
||||
if(file){
|
||||
sprintf(mCurrentSetName, "%s", mDit->d_name);
|
||||
file.close();
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
if (!mDit) {
|
||||
closedir(mDip);
|
||||
mDip = NULL;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
virtual void End()
|
||||
{
|
||||
//mEngine->EnableVSync(false);
|
||||
|
||||
if (bgMusic)
|
||||
{
|
||||
JSoundSystem::GetInstance()->StopMusic(bgMusic);
|
||||
}
|
||||
JRenderer::GetInstance()->EnableVSync(false);
|
||||
}
|
||||
|
||||
|
||||
virtual void Update(float dt)
|
||||
{
|
||||
if (bgMusic && mVolume < 2*GameOptions::GetInstance()->values[OPTIONS_MUSICVOLUME]){
|
||||
mVolume++;
|
||||
JSoundSystem::GetInstance()->SetVolume(mVolume/2);
|
||||
}
|
||||
|
||||
if (currentState == STATE_LOADING_CARDS){
|
||||
if (mReadConf){
|
||||
mParent->collection->load(mCurrentSetFileName, mCurrentSetName);
|
||||
}else{
|
||||
mReadConf = 1;
|
||||
}
|
||||
if (!nextCardSet()){
|
||||
//How many cards total ?
|
||||
sprintf(nbcardsStr, "Database: %i cards", mParent->collection->totalCards());
|
||||
//Check for first time comer
|
||||
std::ifstream file("Res/player/collection.dat");
|
||||
if(file){
|
||||
file.close();
|
||||
currentState = STATE_WARNING;
|
||||
}else{
|
||||
currentState = STATE_FIRST_TIME;
|
||||
}
|
||||
}
|
||||
}else if (currentState == STATE_FIRST_TIME){
|
||||
//Give the player cards from the set for which we have the most variety
|
||||
int setId = 0;
|
||||
int maxcards = 0;
|
||||
for (int i=0; i< MtgSets::SetsList->nb_items; i++){
|
||||
int value = mParent->collection->countBySet(i);
|
||||
if (value > maxcards){
|
||||
maxcards = value;
|
||||
setId = i;
|
||||
}
|
||||
}
|
||||
createUsersFirstDeck(setId);
|
||||
currentState = STATE_WARNING;
|
||||
}else if (currentState == STATE_WARNING){
|
||||
if (!ALPHA_WARNING){
|
||||
currentState = STATE_MENU;
|
||||
}else{
|
||||
if (mEngine->GetButtonClick(PSP_CTRL_CIRCLE)) currentState = STATE_MENU;
|
||||
}
|
||||
}else{
|
||||
if (currentState == STATE_MENU && mGuiController!=NULL)
|
||||
mGuiController->Update(dt);
|
||||
if (currentState == STATE_SUBMENU){
|
||||
if( subMenuController != NULL){
|
||||
subMenuController->Update(dt);
|
||||
}else{
|
||||
subMenuController = NEW SimpleMenu(102, this,mFont, 50,170,SCREEN_WIDTH-120);
|
||||
if (subMenuController){
|
||||
subMenuController->Add(11,"1 Player");
|
||||
subMenuController->Add(12, "2 Players");
|
||||
subMenuController->Add(13,"Demo");
|
||||
subMenuController->Add(14, "Cancel");
|
||||
#ifdef TESTSUITE
|
||||
subMenuController->Add(666, "Test Suite");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentState == STATE_WARNING && !ALPHA_WARNING) currentState = STATE_MENU;
|
||||
}
|
||||
|
||||
void createUsersFirstDeck(int setId){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf, "setID: %i", setId);
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
MTGDeck *mCollection = NEW MTGDeck("Res/player/collection.dat", mParent->cache, mParent->collection);
|
||||
//10 lands of each
|
||||
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Forest")){
|
||||
mCollection->addRandomCards(10, -1,RARITY_L,"Forest");
|
||||
}
|
||||
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Plains")){
|
||||
mCollection->addRandomCards(10, -1,RARITY_L,"Plains");
|
||||
}
|
||||
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Swamp")){
|
||||
mCollection->addRandomCards(10, -1,RARITY_L,"Swamp");
|
||||
}
|
||||
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Mountain")){
|
||||
mCollection->addRandomCards(10, -1,RARITY_L,"Mountain");
|
||||
}
|
||||
if (!mCollection->addRandomCards(10, setId,RARITY_L,"Island")){
|
||||
mCollection->addRandomCards(10, -1,RARITY_L,"Island");
|
||||
}
|
||||
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("1\n");
|
||||
#endif
|
||||
|
||||
//Starter Deck
|
||||
mCollection->addRandomCards(3, setId,RARITY_R,NULL);
|
||||
mCollection->addRandomCards(9, setId,RARITY_U,NULL);
|
||||
mCollection->addRandomCards(48, setId,RARITY_C,NULL);
|
||||
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("2\n");
|
||||
#endif
|
||||
//Boosters
|
||||
for (int i = 0; i< 2; i++){
|
||||
mCollection->addRandomCards(1, setId,RARITY_R);
|
||||
mCollection->addRandomCards(3, setId,RARITY_U);
|
||||
mCollection->addRandomCards(11, setId,RARITY_C);
|
||||
}
|
||||
mCollection->save();
|
||||
delete mCollection;
|
||||
}
|
||||
|
||||
virtual void Render()
|
||||
{
|
||||
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
renderer->ClearScreen(ARGB(0,0,0,0));
|
||||
|
||||
if (currentState == STATE_LOADING_CARDS){
|
||||
char text[512];
|
||||
sprintf(text, "LOADING SET: %s", mCurrentSetName);
|
||||
mFont->DrawString(text,SCREEN_WIDTH/2,SCREEN_HEIGHT/2,JGETEXT_CENTER);
|
||||
}else{
|
||||
|
||||
|
||||
PIXEL_TYPE colors[] =
|
||||
{
|
||||
ARGB(255,17,17,17),
|
||||
ARGB(255,17,17,17),
|
||||
ARGB(255,62,62,62),
|
||||
ARGB(255,62,62,62)
|
||||
};
|
||||
|
||||
|
||||
|
||||
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,colors);
|
||||
renderer->RenderQuad(mBg, SCREEN_WIDTH/2 , 50);
|
||||
if (mGuiController!=NULL)
|
||||
mGuiController->Render();
|
||||
|
||||
mFont->SetScale(0.7);
|
||||
mFont->SetColor(ARGB(128,255,255,255));
|
||||
mFont->DrawString(GAME_VERSION, SCREEN_WIDTH-10,SCREEN_HEIGHT-15,JGETEXT_RIGHT);
|
||||
mFont->DrawString(nbcardsStr,10, SCREEN_HEIGHT-15);
|
||||
mFont->SetScale(1.f);
|
||||
mFont->SetColor(ARGB(255,255,255,255));
|
||||
if (currentState == STATE_SUBMENU && subMenuController != NULL){
|
||||
subMenuController->Render();
|
||||
}
|
||||
|
||||
if (currentState == STATE_WARNING){
|
||||
renderer->FillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,ARGB(128,0,0,0));
|
||||
|
||||
mFont->DrawString("IMPORTANT NOTE" ,SCREEN_WIDTH/2,10,JGETEXT_CENTER);
|
||||
mFont->DrawString("This is an alpha version with lots of bugs.",SCREEN_WIDTH/2,35,JGETEXT_CENTER);
|
||||
mFont->DrawString("It WILL crash your psp" ,SCREEN_WIDTH/2,50,JGETEXT_CENTER);
|
||||
mFont->DrawString("If you use it anyway, your feedback is welcome" ,SCREEN_WIDTH/2,65,JGETEXT_CENTER);
|
||||
|
||||
mFont->DrawString("This freeware game is NOT published or endorsed" ,SCREEN_WIDTH/2,110,JGETEXT_CENTER);
|
||||
mFont->DrawString("by Wizard of the Coast, Inc." ,SCREEN_WIDTH/2,125,JGETEXT_CENTER);
|
||||
mFont->DrawString("Infos & updates at http://wololo.net/wagic/" ,SCREEN_WIDTH/2,170,JGETEXT_CENTER);
|
||||
mFont->DrawString("PRESS CIRCLE TO CONTINUE OR HOME TO QUIT" ,SCREEN_WIDTH/2,210,JGETEXT_CENTER);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual void ButtonPressed(int controllerId, int controlId)
|
||||
{
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
char buf[4096];
|
||||
sprintf(buf, "cnotrollerId: %i", controllerId);
|
||||
OutputDebugString(buf);
|
||||
#endif
|
||||
switch (controllerId){
|
||||
case 101:
|
||||
createUsersFirstDeck(controlId);
|
||||
currentState = STATE_MENU;
|
||||
SAFE_DELETE(subMenuController);
|
||||
break;
|
||||
default:
|
||||
switch (controlId)
|
||||
{
|
||||
case 1:
|
||||
currentState = STATE_SUBMENU;
|
||||
break;
|
||||
case 2:
|
||||
mParent->SetNextState(GAME_STATE_DECK_VIEWER);
|
||||
break;
|
||||
case 3:
|
||||
mParent->SetNextState(GAME_STATE_SHOP);
|
||||
break;
|
||||
case 4:
|
||||
mParent->SetNextState(GAME_STATE_OPTIONS);
|
||||
break;
|
||||
case 5:
|
||||
mEngine->End();
|
||||
break;
|
||||
case 11:
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[1] = PLAYER_TYPE_CPU;
|
||||
mParent->SetNextState(GAME_STATE_DUEL);
|
||||
break;
|
||||
case 12:
|
||||
mParent->players[0] = PLAYER_TYPE_HUMAN;
|
||||
mParent->players[1] = PLAYER_TYPE_HUMAN;
|
||||
mParent->SetNextState(GAME_STATE_DUEL);
|
||||
break;
|
||||
case 13:
|
||||
mParent->players[0] = PLAYER_TYPE_CPU;
|
||||
mParent->players[1] = PLAYER_TYPE_CPU;
|
||||
mParent->SetNextState(GAME_STATE_DUEL);
|
||||
break;
|
||||
case 14:
|
||||
currentState = STATE_MENU;
|
||||
delete subMenuController;
|
||||
subMenuController = NULL;
|
||||
break;
|
||||
#ifdef TESTSUITE
|
||||
case 666:
|
||||
mParent->players[0] = PLAYER_TYPE_TESTSUITE;
|
||||
mParent->players[1] = PLAYER_TYPE_TESTSUITE;
|
||||
mParent->SetNextState(GAME_STATE_DUEL);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
34
projects/mtg/include/GameStateOptions.h
Normal file
34
projects/mtg/include/GameStateOptions.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _GAME_STATE_OPTIONS_H_
|
||||
#define _GAME_STATE_OPTIONS_H_
|
||||
|
||||
#include <JGui.h>
|
||||
#include "../include/GameState.h"
|
||||
|
||||
#define SHOW_OPTIONS 1
|
||||
#define SHOW_OPTIONS_MENU 2
|
||||
|
||||
class GameApp;
|
||||
class OptionsList;
|
||||
class SimpleMenu;
|
||||
|
||||
class GameStateOptions: public GameState, public JGuiListener
|
||||
{
|
||||
|
||||
public:
|
||||
SimpleMenu * optionsMenu;
|
||||
int mState;
|
||||
OptionsList * optionsList;
|
||||
GameStateOptions(GameApp* parent);
|
||||
virtual ~GameStateOptions();
|
||||
|
||||
virtual void Start();
|
||||
virtual void End();
|
||||
virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
void ButtonPressed(int controllerId, int ControlId);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
46
projects/mtg/include/GameStateShop.h
Normal file
46
projects/mtg/include/GameStateShop.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef _GAME_STATE_SHOP_H_
|
||||
#define _GAME_STATE_SHOP_H_
|
||||
|
||||
#include <JGE.h>
|
||||
#include "../include/GameState.h"
|
||||
#include "../include/SimpleMenu.h"
|
||||
#include "../include/ShopItem.h"
|
||||
|
||||
|
||||
#define STATE_BUY 1
|
||||
#define STATE_SELL 2
|
||||
#define STAGE_SHOP_MENU 3
|
||||
#define STAGE_SHOP_SHOP 4
|
||||
|
||||
class GameStateShop: public GameState, public JGuiListener
|
||||
{
|
||||
private:
|
||||
|
||||
ShopItems * shop;
|
||||
JLBFont * mFont;
|
||||
JQuad * mBg;
|
||||
JTexture * bgTexture;
|
||||
JQuad * mBack;
|
||||
JTexture * backTexture;
|
||||
SimpleMenu * menu;
|
||||
int mStage;
|
||||
char starterBuffer[128], boosterBuffer[128];
|
||||
int setId;
|
||||
|
||||
public:
|
||||
GameStateShop(GameApp* parent);
|
||||
virtual ~GameStateShop();
|
||||
|
||||
virtual void Start();
|
||||
virtual void End();
|
||||
virtual void Create();
|
||||
virtual void Destroy();
|
||||
virtual void Update(float dt);
|
||||
virtual void Render();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
39
projects/mtg/include/GroupOfCards.h
Normal file
39
projects/mtg/include/GroupOfCards.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef _GROUPOFCARDS_H_
|
||||
#define _GROUPOFCARDS_H_
|
||||
|
||||
#include "GameObserver.h"
|
||||
#include "MTGCardInstance.h"
|
||||
|
||||
#define FILTER_SUBTYPE 1
|
||||
|
||||
#define GROUP_LIMIT 10
|
||||
|
||||
class GroupOfCards{
|
||||
protected:
|
||||
GameObserver * game;
|
||||
public:
|
||||
GroupOfCards(GameObserver * _game);
|
||||
//virtual ~GroupOfCards();
|
||||
virtual int includes(MTGCardInstance * card){return 0;};
|
||||
};
|
||||
|
||||
class GroupOfCreatures:public GroupOfCards{
|
||||
protected:
|
||||
int filter;
|
||||
int filterValue;
|
||||
public:
|
||||
GroupOfCreatures(GameObserver * _game, int _filter, int _filterValue);
|
||||
int includes(MTGCardInstance * card);
|
||||
};
|
||||
|
||||
class GroupOfSpecificCards:public GroupOfCards{
|
||||
protected:
|
||||
int nb_cards;
|
||||
MTGCardInstance * cards[GROUP_LIMIT];
|
||||
public:
|
||||
int includes(MTGCardInstance * card);
|
||||
GroupOfSpecificCards(GameObserver * _game, MTGCardInstance * _creatures[], int _nb_creatures);
|
||||
GroupOfSpecificCards(GameObserver * _game, MTGCardInstance * card);
|
||||
};
|
||||
|
||||
#endif
|
||||
6
projects/mtg/include/GroupOfCreatures.h
Normal file
6
projects/mtg/include/GroupOfCreatures.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#ifndef _GROUPOFCREATURES_H_
|
||||
#define _GROUPOFCREATURES_H_
|
||||
|
||||
class Group
|
||||
|
||||
#endif
|
||||
13
projects/mtg/include/GuiCardsController.h
Normal file
13
projects/mtg/include/GuiCardsController.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _GUI_CARDS_CONTROLLER_H_
|
||||
#define _GUI_CARDS_CONTROLLER_H_
|
||||
|
||||
|
||||
#include "PlayGuiObjectController.h"
|
||||
|
||||
class GuiCardsController : public PlayGuiObjectController{
|
||||
public:
|
||||
GuiCardsController(int id, GameObserver* _game):PlayGuiObjectController(id, _game){};
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
58
projects/mtg/include/GuiLayers.h
Normal file
58
projects/mtg/include/GuiLayers.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef _GUI_LAYERS_H_
|
||||
#define _GUI_LAYERS_H_
|
||||
|
||||
#define MAX_GUI_LAYERS 6
|
||||
|
||||
#define DIR_DOWN 1
|
||||
#define DIR_UP 2
|
||||
#define DIR_LEFT 3
|
||||
#define DIR_RIGHT 4
|
||||
|
||||
#include <JGui.h>
|
||||
|
||||
|
||||
class GameObserver;
|
||||
class Player;
|
||||
|
||||
class GuiLayer: public JGuiController{
|
||||
protected:
|
||||
int modal;
|
||||
GameObserver * game;
|
||||
public:
|
||||
virtual void resetObjects();
|
||||
int hasFocus;
|
||||
int getMaxId();
|
||||
void RenderMessageBackground(float x0, float y0, float width, int height);
|
||||
void RenderMessageBackground(float y0, int height);
|
||||
GuiLayer(int id, GameObserver* _game);
|
||||
virtual int isModal();
|
||||
void setModal(int _modal);
|
||||
virtual ~GuiLayer();
|
||||
virtual void Update(float dt);
|
||||
virtual void CheckUserInput(float dt){};
|
||||
virtual int unstopableRenderInProgress(){return 0;};
|
||||
int getIndexOf(JGuiObject * object);
|
||||
JGuiObject * getByIndex (int index);
|
||||
virtual void Render(){JGuiController::Render();};
|
||||
int empty(){
|
||||
if (mCount) return 0;
|
||||
return 1;
|
||||
};
|
||||
};
|
||||
|
||||
class GuiLayers{
|
||||
protected:
|
||||
int nbitems;
|
||||
GuiLayer * objects[MAX_GUI_LAYERS];
|
||||
public:
|
||||
GuiLayers();
|
||||
void Update(float dt, Player * player);
|
||||
void Render();
|
||||
void Add(GuiLayer * layer);
|
||||
void Remove();
|
||||
int unstopableRenderInProgress();
|
||||
~GuiLayers();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
20
projects/mtg/include/Logger.h
Normal file
20
projects/mtg/include/Logger.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _LOGGER_H
|
||||
#define _LOGGER_H_
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef DOLOG
|
||||
#define LOG(x) Logger::Log(x);
|
||||
#else
|
||||
#define LOG(x)
|
||||
#endif
|
||||
|
||||
#define LOG_FILE "Res/debug.txt"
|
||||
|
||||
class Logger{
|
||||
public:
|
||||
static void Log(char * text);
|
||||
};
|
||||
|
||||
#endif
|
||||
117
projects/mtg/include/MTGAbility.h
Normal file
117
projects/mtg/include/MTGAbility.h
Normal file
@@ -0,0 +1,117 @@
|
||||
#ifndef _MTGABILITY_H_
|
||||
#define _MTGABILITY_H_
|
||||
|
||||
|
||||
|
||||
class MTGCardInstance;
|
||||
class GameObserver;
|
||||
class Spell;
|
||||
class Damageable;
|
||||
class PlayGuiObject;
|
||||
class TargetChooser;
|
||||
class ManaCost;
|
||||
class MTGGameZone;
|
||||
class Player;
|
||||
|
||||
#include "ActionElement.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
using std::string;
|
||||
using std::map;
|
||||
|
||||
|
||||
#define BAKA_EFFECT_GOOD 10
|
||||
#define BAKA_EFFECT_BAD 11
|
||||
|
||||
class AbilityFactory{
|
||||
private:
|
||||
int destroyAllFromTypeInPlay(const char * type, MTGCardInstance * source, int bury = 0);
|
||||
int putInPlayFromZone(MTGCardInstance * card, MTGGameZone * zone, Player * p);
|
||||
public:
|
||||
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL);
|
||||
void addAbilities(int _id, Spell * spell);
|
||||
};
|
||||
|
||||
class MTGAbility: public ActionElement{
|
||||
protected:
|
||||
char menuText[25];
|
||||
Damageable * target;
|
||||
GameObserver * game;
|
||||
public:
|
||||
MTGCardInstance * source;
|
||||
MTGAbility(int id, MTGCardInstance * card);
|
||||
MTGAbility(int id, MTGCardInstance * _source, Damageable * _target);
|
||||
virtual int testDestroy();
|
||||
virtual ~MTGAbility();
|
||||
virtual void Render(){};
|
||||
virtual int isReactingToClick(MTGCardInstance * card){return 0;};
|
||||
virtual int reactToClick(MTGCardInstance * card){return 0;};
|
||||
virtual void Update(float dt){};
|
||||
virtual int fireAbility();
|
||||
virtual int resolve(){return 0;};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class TriggeredAbility:public MTGAbility{
|
||||
public:
|
||||
TriggeredAbility(int id, MTGCardInstance * card);
|
||||
TriggeredAbility(int id, MTGCardInstance * _source, Damageable * _target);
|
||||
virtual void Update(float dt);
|
||||
virtual void Render(){};
|
||||
virtual int trigger()=0;
|
||||
virtual int resolve() = 0;
|
||||
};
|
||||
|
||||
|
||||
class ActivatedAbility:public MTGAbility{
|
||||
public:
|
||||
ManaCost * cost;
|
||||
int playerturnonly;
|
||||
int needsTapping;
|
||||
ActivatedAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
|
||||
virtual int reactToClick(MTGCardInstance * card);
|
||||
virtual int isReactingToClick(MTGCardInstance * card);
|
||||
virtual int reactToTargetClick(Targetable * object);
|
||||
virtual int resolve() = 0;
|
||||
virtual ~ActivatedAbility();
|
||||
};
|
||||
|
||||
class TargetAbility:public ActivatedAbility{
|
||||
public:
|
||||
TargetAbility(int id, MTGCardInstance * card, TargetChooser * _tc,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
|
||||
TargetAbility(int id, MTGCardInstance * card,ManaCost * _cost = NULL, int _playerturnonly = 0,int tap = 1);
|
||||
virtual void Update(float dt);
|
||||
virtual int reactToClick(MTGCardInstance * card);
|
||||
virtual int reactToTargetClick(Targetable * object);
|
||||
virtual void Render();
|
||||
};
|
||||
|
||||
class InstantAbility:public MTGAbility{
|
||||
public:
|
||||
int init;
|
||||
virtual void Update(float dt);
|
||||
virtual int testDestroy();
|
||||
InstantAbility(int _id, MTGCardInstance * source);
|
||||
InstantAbility(int _id, MTGCardInstance * source,Damageable * _target);
|
||||
virtual int resolve(){return 0;};
|
||||
};
|
||||
|
||||
/* State based effects. This class works ONLY for InPlay and needs to be extended for other areas of the game !!! */
|
||||
class ListMaintainerAbility:public MTGAbility{
|
||||
public:
|
||||
map<MTGCardInstance *,bool> cards;
|
||||
ListMaintainerAbility(int _id):MTGAbility(_id,NULL){};
|
||||
ListMaintainerAbility(int _id, MTGCardInstance *_source):MTGAbility(_id, _source){};
|
||||
ListMaintainerAbility(int _id, MTGCardInstance *_source,Damageable * _target):MTGAbility(_id, _source, _target){};
|
||||
virtual void Update(float dt);
|
||||
virtual int canBeInList(MTGCardInstance * card) = 0;
|
||||
virtual int added(MTGCardInstance * card) = 0;
|
||||
virtual int removed(MTGCardInstance * card) = 0;
|
||||
virtual int destroy();
|
||||
};
|
||||
|
||||
#include "MTGCardInstance.h"
|
||||
|
||||
#endif
|
||||
119
projects/mtg/include/MTGCard.h
Normal file
119
projects/mtg/include/MTGCard.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef _MTGCARD_H_
|
||||
#define _MTGCARD_H_
|
||||
|
||||
#define MTGCARD_NAME_SIZE 30
|
||||
#define MTGCARD_TEXT_SIZE 300
|
||||
|
||||
#define MTG_IMAGE_WIDTH 200
|
||||
#define MTG_IMAGE_HEIGHT 285
|
||||
|
||||
|
||||
#define MAX_TYPES_PER_CARD 10
|
||||
|
||||
|
||||
|
||||
|
||||
#include "ManaCost.h"
|
||||
|
||||
|
||||
class TexturesCache;
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
class MTGCard {
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
int mtgid;
|
||||
TexturesCache * mCache;
|
||||
ManaCost manaCost;
|
||||
|
||||
|
||||
char rarity;
|
||||
|
||||
char image_name[MTGCARD_NAME_SIZE];
|
||||
|
||||
int init();
|
||||
|
||||
public:
|
||||
string text;
|
||||
string name;
|
||||
int colors[MTG_NB_COLORS];
|
||||
int basicAbilities[NB_BASIC_ABILITIES];
|
||||
vector<string> formattedText;
|
||||
string magicText;
|
||||
int alias;
|
||||
string spellTargetType;
|
||||
int formattedTextInit;
|
||||
int power;
|
||||
int toughness;
|
||||
int setId;
|
||||
static const char * const Colors_To_Text[];
|
||||
int nb_types;
|
||||
int types[MAX_TYPES_PER_CARD];
|
||||
MTGCard();
|
||||
MTGCard(TexturesCache * cache, int set_id);
|
||||
MTGCard(MTGCard * source);
|
||||
JQuad * getQuad(TexturesCache * cache);
|
||||
JQuad * getQuad(int type=1);
|
||||
JQuad * getThumb();
|
||||
|
||||
void setColor(int _color, int removeAllOthers = 0);
|
||||
int getColor();
|
||||
int hasColor(int _color);
|
||||
const char * colorToString();
|
||||
|
||||
void setMTGId(int id);
|
||||
int getMTGId();
|
||||
int getId();
|
||||
|
||||
int has(int ability);
|
||||
|
||||
char getRarity();
|
||||
void setRarity(char _rarity);
|
||||
|
||||
const char * getSetName();
|
||||
|
||||
//void setImageName( char * value);
|
||||
char * getImageName ();
|
||||
|
||||
void setText( string value);
|
||||
const char * getText();
|
||||
|
||||
void addMagicText(string value);
|
||||
|
||||
void setName( string value);
|
||||
const char * getName();
|
||||
|
||||
void addType(char * type_text);
|
||||
void addType(int id);
|
||||
void setType(const char * type_text);
|
||||
void setSubtype( string value);
|
||||
int removeType(string value, int removeAll = 0);
|
||||
int removeType(int value, int removeAll = 0);
|
||||
int hasSubtype(int _subtype);
|
||||
int hasSubtype(const char * _subtype);
|
||||
int hasSubtype(string _subtype);
|
||||
int hasType(int _type);
|
||||
int hasType(const char * type);
|
||||
|
||||
void setManaCost(string value);
|
||||
ManaCost * getManaCost();
|
||||
int isACreature();
|
||||
|
||||
void setPower(int _power);
|
||||
int getPower();
|
||||
void setToughness(int _toughness);
|
||||
int getToughness();
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
102
projects/mtg/include/MTGCardInstance.h
Normal file
102
projects/mtg/include/MTGCardInstance.h
Normal file
@@ -0,0 +1,102 @@
|
||||
#ifndef _MTG_CARD_INSTANCE_H_
|
||||
#define _MTG_CARD_INSTANCE_H_
|
||||
|
||||
#include "MTGCard.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "MTGAbility.h"
|
||||
#include "TexturesCache.h"
|
||||
#include "ManaCost.h"
|
||||
#include "Blocker.h"
|
||||
#include "Damage.h"
|
||||
#include "Targetable.h"
|
||||
|
||||
|
||||
class MTGCardInstance;
|
||||
class MTGPlayerCards;
|
||||
class MTGAbility;
|
||||
class MTGCard;
|
||||
class TexturesCache;
|
||||
class ManaCost;
|
||||
class Blockers;
|
||||
class CardDescriptor;
|
||||
class Counters;
|
||||
|
||||
|
||||
|
||||
class MTGCardInstance: public MTGCard, public Damageable, public Targetable {
|
||||
protected:
|
||||
int untapping;
|
||||
int nb_damages;
|
||||
|
||||
|
||||
int lifeOrig;
|
||||
Blockers * blockers;
|
||||
MTGPlayerCards * belongs_to;
|
||||
MTGAbility * UntapBlockers[10];
|
||||
void unband();
|
||||
MTGCardInstance * getNextPartner();
|
||||
void initMTGCI();
|
||||
public:
|
||||
MTGGameZone * getCurrentZone();
|
||||
int doDamageTest;
|
||||
int summoningSickness;
|
||||
// The recommended method to test for summoning Sickness !
|
||||
int hasSummoningSickness();
|
||||
int changeController(Player * newcontroller);
|
||||
MTGCardInstance * defenser;
|
||||
float changedZoneRecently;
|
||||
Player * owner;
|
||||
Counters * counters;
|
||||
int typeAsTarget(){return TARGET_CARD;}
|
||||
int attacker;
|
||||
MTGCardInstance * banding; // If belongs to a band when attacking
|
||||
MTGCardInstance * target;
|
||||
int tapped;
|
||||
void addType(int type);
|
||||
int canBlock();
|
||||
int canBlock(MTGCardInstance * opponent);
|
||||
int canAttack();
|
||||
int afterDamage();
|
||||
void setUntapping();
|
||||
int isUntapping();
|
||||
int has(int ability);
|
||||
int cleanup();
|
||||
int reset();
|
||||
int isAttacker();
|
||||
MTGCardInstance * isDefenser();
|
||||
int toggleDefenser(MTGCardInstance * opponent);
|
||||
int toggleAttacker();
|
||||
MTGCard * model;
|
||||
MTGCardInstance();
|
||||
MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to);
|
||||
Blockers * getBlockers();
|
||||
void regenerate();
|
||||
Player * controller();
|
||||
JQuad * getIcon();
|
||||
int initAttackersDefensers();
|
||||
MTGCardInstance * getNextOpponent(MTGCardInstance * previous=NULL);
|
||||
int nbOpponents();
|
||||
~MTGCardInstance();
|
||||
|
||||
|
||||
int addToToughness(int value);
|
||||
int setToughness(int value);
|
||||
|
||||
CardDescriptor * protections[10];
|
||||
int nbprotections;
|
||||
int addProtection(CardDescriptor * cd);
|
||||
int removeProtection(CardDescriptor *cd, int erase = 0);
|
||||
int protectedAgainst(MTGCardInstance * card);
|
||||
|
||||
// in game
|
||||
int isTapped();
|
||||
void untap();
|
||||
void tap();
|
||||
int isInPlay();
|
||||
void resetAllDamage();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
91
projects/mtg/include/MTGDeck.h
Normal file
91
projects/mtg/include/MTGDeck.h
Normal file
@@ -0,0 +1,91 @@
|
||||
#ifndef _MTGDECK_H_
|
||||
#define _MTGDECK_H_
|
||||
|
||||
#define MTG_ERROR -1
|
||||
|
||||
#include "../include/MTGDefinitions.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../include/GameApp.h"
|
||||
#include "../include/TexturesCache.h"
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
class GameApp;
|
||||
class MTGCard;
|
||||
|
||||
|
||||
#define MAX_SETS 30
|
||||
|
||||
|
||||
|
||||
class MtgSets{
|
||||
protected:
|
||||
public:
|
||||
int nb_items;
|
||||
string values[MAX_SETS];
|
||||
|
||||
public:
|
||||
static MtgSets * SetsList;
|
||||
MtgSets();
|
||||
int Add(const char * subtype);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class MTGAllCards {
|
||||
protected:
|
||||
int conf_read_mode;
|
||||
int conf_fd;
|
||||
char * conf_buffer;
|
||||
int read_cursor;
|
||||
int colorsCount[MTG_NB_COLORS];
|
||||
int total_cards;
|
||||
GameApp * parent;
|
||||
void init();
|
||||
void initCounters();
|
||||
public:
|
||||
|
||||
TexturesCache * mCache;
|
||||
MTGCard * _(int i);
|
||||
MTGCard * collection[TOTAL_NUMBER_OF_CARDS];
|
||||
MTGAllCards();
|
||||
~MTGAllCards();
|
||||
MTGAllCards(TexturesCache * cache);
|
||||
void destroyAllCards();
|
||||
MTGAllCards(const char * config_file, const char * set_name);
|
||||
MTGAllCards(const char * config_file, const char * set_name, TexturesCache * cache);
|
||||
MTGCard * getCardById(int id);
|
||||
int load(const char * config_file, const char * setName, int autoload = 1);
|
||||
int countByType(const char * _type);
|
||||
int countByColor(int color);
|
||||
int countBySet(int setId);
|
||||
int readConfLine(int set_id);
|
||||
int totalCards();
|
||||
int randomCardId();
|
||||
private:
|
||||
int processConfLine(char* file, MTGCard* card);
|
||||
};
|
||||
|
||||
|
||||
class MTGDeck:public MTGAllCards{
|
||||
protected:
|
||||
string filename;
|
||||
MTGAllCards * allcards;
|
||||
public:
|
||||
MTGDeck(const char * config_file, TexturesCache * cache, MTGAllCards * _allcards);
|
||||
int addRandomCards(int howmany, int setId = -1, int rarity = -1, const char * subtype = NULL);
|
||||
int add(int cardid);
|
||||
int remove(int cardid);
|
||||
int removeAll();
|
||||
int add(MTGCard * card);
|
||||
int remove(MTGCard * card);
|
||||
int save();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
151
projects/mtg/include/MTGDefinitions.h
Normal file
151
projects/mtg/include/MTGDefinitions.h
Normal file
@@ -0,0 +1,151 @@
|
||||
#ifndef _MTGDEFINITION_H_
|
||||
#define _MTGDEFINITION_H_
|
||||
|
||||
|
||||
#define TOTAL_NUMBER_OF_CARDS 4000
|
||||
|
||||
#define MTG_NB_COLORS 7
|
||||
|
||||
#define MTG_COLOR_ARTIFACT 0
|
||||
#define MTG_COLOR_GREEN 1
|
||||
#define MTG_COLOR_BLUE 2
|
||||
#define MTG_COLOR_RED 3
|
||||
#define MTG_COLOR_BLACK 4
|
||||
#define MTG_COLOR_WHITE 5
|
||||
#define MTG_COLOR_LAND 6
|
||||
|
||||
|
||||
static char MTGColorChars[] = {'x','g','u','r','b','w','l'};
|
||||
static int _r[7] = {75, 20, 20, 200,50,255,128};
|
||||
static int _g[7] = {30, 140, 30, 15, 50,255,128};
|
||||
static int _b[7] = {20, 0, 140,15, 50,255,128};
|
||||
|
||||
|
||||
#define MTG_UNCOLORED 0
|
||||
#define MTG_FOREST 1
|
||||
#define MTG_ISLAND 2
|
||||
#define MTG_MOUNTAIN 3
|
||||
#define MTG_SWAMP 4
|
||||
#define MTG_PLAIN 5
|
||||
|
||||
#define MTG_TYPE_CREATURE 10
|
||||
#define MTG_TYPE_ARTIFACT 11
|
||||
#define MTG_TYPE_ENCHANTMENT 12
|
||||
#define MTG_TYPE_SORCERY 13
|
||||
#define MTG_TYPE_LAND 14
|
||||
#define MTG_TYPE_INSTANT 15
|
||||
|
||||
|
||||
|
||||
#define MTG_PHASE_UNTAP 0
|
||||
#define MTG_PHASE_UPKEEP 1
|
||||
#define MTG_PHASE_DRAW 2
|
||||
#define MTG_PHASE_FIRSTMAIN 3
|
||||
#define MTG_PHASE_COMBATBEGIN 4
|
||||
#define MTG_PHASE_COMBATATTACKERS 5
|
||||
#define MTG_PHASE_COMBATBLOCKERS 6
|
||||
#define MTG_PHASE_COMBATDAMAGE 7
|
||||
#define MTG_PHASE_COMBATEND 8
|
||||
#define MTG_PHASE_SECONDMAIN 9
|
||||
#define MTG_PHASE_ENDOFTURN 10
|
||||
#define MTG_PHASE_EOT 10
|
||||
#define MTG_PHASE_CLEANUP 11
|
||||
|
||||
|
||||
#define TRAMPLE 0
|
||||
#define FORESTWALK 1
|
||||
#define ISLANDWALK 2
|
||||
#define MOUNTAINWALK 3
|
||||
#define SWAMPWALK 4
|
||||
#define PLAINSWALK 5
|
||||
#define FLYING 6
|
||||
#define FIRSTSTRIKE 7
|
||||
#define DOUBLESTRIKE 8
|
||||
#define FEAR 9
|
||||
#define FLASH 10
|
||||
#define HASTE 11
|
||||
#define LIFELINK 12
|
||||
#define REACH 13
|
||||
#define SHROUD 14
|
||||
#define VIGILANCE 15
|
||||
#define DEFENSER 16
|
||||
#define BANDING 17
|
||||
#define PROTECTIONGREEN 18
|
||||
#define PROTECTIONBLUE 19
|
||||
#define PROTECTIONRED 20
|
||||
#define PROTECTIONBLACK 21
|
||||
#define PROTECTIONWHITE 22
|
||||
#define UNBLOCKABLE 23
|
||||
#define WITHER 24
|
||||
#define PERSIST 25
|
||||
#define RETRACE 26
|
||||
#define EXALTED 27
|
||||
#define LEGENDARY 28
|
||||
|
||||
#define NB_BASIC_ABILITIES 29
|
||||
|
||||
static const char * MTGBasicAbilities[] = {
|
||||
"trample",
|
||||
"forestwalk",
|
||||
"islandwalk",
|
||||
"mountainwalk",
|
||||
"swampwalk",
|
||||
"plainwalk",
|
||||
"flying",
|
||||
"first strike",
|
||||
"double strike",
|
||||
"fear",
|
||||
"flash",
|
||||
"haste",
|
||||
"lifelink",
|
||||
"reach",
|
||||
"shroud",
|
||||
"vigilance",
|
||||
"defender",
|
||||
"banding",
|
||||
"protection from green",
|
||||
"protection from blue",
|
||||
"protection from red",
|
||||
"protection from black",
|
||||
"protection from white",
|
||||
"unblockable",
|
||||
"wither",
|
||||
"persist",
|
||||
"retrace",
|
||||
"exalted",
|
||||
"legendary"
|
||||
};
|
||||
|
||||
|
||||
#define RARITY_M 'M'
|
||||
#define RARITY_R 'R'
|
||||
#define RARITY_U 'U'
|
||||
#define RARITY_C 'C'
|
||||
#define RARITY_L 'L'
|
||||
|
||||
|
||||
#define MAIN_FONT 0
|
||||
#define MAGIC_FONT 1
|
||||
|
||||
|
||||
static const char *MTGPhaseNames[] =
|
||||
{
|
||||
"Untap",
|
||||
"Upkeep",
|
||||
"Draw",
|
||||
"Main phase 1",
|
||||
"Combat begins",
|
||||
"Attackers",
|
||||
"Blockers",
|
||||
"Combat damage",
|
||||
"Combat ends",
|
||||
"Main phase 2",
|
||||
"End of turn",
|
||||
"cleanup"
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
24
projects/mtg/include/MTGGamePhase.h
Normal file
24
projects/mtg/include/MTGGamePhase.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _MTGGAMEPHASE_H_
|
||||
#define _MTGGAMEPHASE_H_
|
||||
|
||||
#include "ActionElement.h"
|
||||
#include "GameObserver.h"
|
||||
|
||||
#include <JGui.h>
|
||||
#include <JLBFont.h>
|
||||
|
||||
|
||||
class MTGGamePhase: public ActionElement {
|
||||
protected:
|
||||
float animation;
|
||||
int currentState;
|
||||
JLBFont * mFont;
|
||||
public:
|
||||
MTGGamePhase(int id);
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
void CheckUserInput(float dt);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
93
projects/mtg/include/MTGGameZones.h
Normal file
93
projects/mtg/include/MTGGameZones.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _MTGGAMEZONES_H_
|
||||
#define _MTGGAMEZONES_H_
|
||||
|
||||
#include "MTGDeck.h"
|
||||
#include "MTGCardInstance.h"
|
||||
|
||||
#define MTG_MAX_PLAYER_CARDS 100
|
||||
|
||||
class MTGAllCards;
|
||||
class MTGCardInstance;
|
||||
class Player;
|
||||
|
||||
class MTGGameZone {
|
||||
protected:
|
||||
Player * owner;
|
||||
public:
|
||||
MTGCardInstance * cards[MTG_MAX_PLAYER_CARDS];
|
||||
int nb_cards;
|
||||
MTGGameZone();
|
||||
~MTGGameZone();
|
||||
void shuffle();
|
||||
virtual MTGCardInstance * draw();
|
||||
void addCard(MTGCardInstance * card);
|
||||
void debugPrint();
|
||||
MTGCardInstance * removeCard(MTGCardInstance * card);
|
||||
MTGCardInstance * hasCard(MTGCardInstance * card);
|
||||
void cleanupPhase();
|
||||
int countByType(const char * value);
|
||||
int hasType(const char * value);
|
||||
void setOwner(Player * player);
|
||||
MTGCardInstance * lastCardDrawn;
|
||||
};
|
||||
|
||||
class MTGLibrary: public MTGGameZone {
|
||||
public:
|
||||
// MTGLibrary();
|
||||
void shuffleTopToBottom(int nbcards);
|
||||
MTGCardInstance * draw();
|
||||
};
|
||||
|
||||
class MTGGraveyard: public MTGGameZone {
|
||||
public:
|
||||
// MTGGraveyard();
|
||||
};
|
||||
|
||||
class MTGHand: public MTGGameZone {
|
||||
public:
|
||||
};
|
||||
|
||||
|
||||
class MTGStack: public MTGGameZone {
|
||||
public:
|
||||
};
|
||||
|
||||
class MTGInPlay: public MTGGameZone {
|
||||
public:
|
||||
//MTGInPlay();
|
||||
void untapAll();
|
||||
MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
|
||||
MTGCardInstance * getNextDefenser(MTGCardInstance * previous, MTGCardInstance * attacker);
|
||||
int nbDefensers( MTGCardInstance * attacker);
|
||||
int nbPartners(MTGCardInstance * attacker);
|
||||
};
|
||||
|
||||
|
||||
class MTGPlayerCards {
|
||||
protected:
|
||||
void init();
|
||||
|
||||
public:
|
||||
MTGLibrary * library;
|
||||
MTGGraveyard * graveyard;
|
||||
MTGHand * hand;
|
||||
MTGInPlay * inPlay;
|
||||
MTGStack * stack;
|
||||
MTGAllCards * collection;
|
||||
|
||||
MTGPlayerCards(MTGAllCards * _collection, int * idList, int idListSize);
|
||||
~MTGPlayerCards();
|
||||
void initGame(int shuffle = 1, int draw = 1);
|
||||
void setOwner(Player * player);
|
||||
void discardRandom(MTGGameZone * from);
|
||||
void drawFromLibrary();
|
||||
void showHand();
|
||||
void putInGraveyard(MTGCardInstance * card);
|
||||
void putInZone(MTGCardInstance * card, MTGGameZone * from, MTGGameZone * to);
|
||||
void putInPlay(MTGCardInstance * card);
|
||||
int isInPlay(MTGCardInstance * card);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
34
projects/mtg/include/MTGGuiHand.h
Normal file
34
projects/mtg/include/MTGGuiHand.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _MTGGUIHAND_H_
|
||||
#define _MTGGUIHAND_H_
|
||||
|
||||
|
||||
|
||||
#include "GuiCardsController.h"
|
||||
#include "Player.h"
|
||||
#include "GameObserver.h"
|
||||
|
||||
#define HAND_SHOW_ANIMATION 1
|
||||
#define HAND_HIDE_ANIMATION 2
|
||||
#define HAND_SHOW 3
|
||||
#define HAND_HIDE 4
|
||||
|
||||
class Player;
|
||||
class GuiCardscontroller;
|
||||
|
||||
class MTGGuiHand: public GuiCardsController{
|
||||
protected:
|
||||
int currentId[2];
|
||||
Player * currentPlayer;
|
||||
int mShowHand;
|
||||
float mAnimState;
|
||||
JLBFont * mFont;
|
||||
public:
|
||||
MTGGuiHand(int id, GameObserver * _game);
|
||||
void Update(float dt);
|
||||
void CheckUserInput(float dt);
|
||||
virtual void Render();
|
||||
void updateCards();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
57
projects/mtg/include/MTGGuiPlay.h
Normal file
57
projects/mtg/include/MTGGuiPlay.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef _MTGGUIPLAY_H_
|
||||
#define _MTGGUIPLAY_H_
|
||||
|
||||
#define MAX_ATTACKERS 20
|
||||
|
||||
#include "PlayGuiObjectController.h"
|
||||
#include "Player.h"
|
||||
|
||||
class Player;
|
||||
class GameObserver;
|
||||
class CardGui;
|
||||
|
||||
class MTGGuiPlay: public PlayGuiObjectController {
|
||||
protected:
|
||||
int offset;
|
||||
Player * currentPlayer;
|
||||
MTGCardInstance * cardsGrid[SCREEN_WIDTH/5][SCREEN_HEIGHT/5];
|
||||
int nb_creatures;
|
||||
int nb_spells;
|
||||
int nb_lands;
|
||||
int cards_x_limit;
|
||||
|
||||
JQuad * phaseIcons[24];
|
||||
JQuad * mGlitter;
|
||||
int mGlitterAlpha;
|
||||
float mGlitterX, mGlitterY;
|
||||
JTexture * mPhaseBarTexture;
|
||||
JQuad * mIcons[7];
|
||||
JTexture * mIconsTexture;
|
||||
JTexture * mBgTex;
|
||||
JQuad * mBg;
|
||||
|
||||
JTexture * mBgTex2;
|
||||
JQuad * mBg2;
|
||||
int alphaBg[4];
|
||||
void RenderPhaseBar();
|
||||
void RenderPlayerInfo(int player);
|
||||
JLBFont* mFont;
|
||||
|
||||
void AddPlayersGuiInfo();
|
||||
void initCardsDisplay();
|
||||
void setCardPosition(CardGui * cardg, int player, int playerTurn, int spellMode);
|
||||
void setTargettingCardPosition(CardGui * cardg, int player, int playerTurn);
|
||||
void adjustCardPosition(CardGui * cardg);
|
||||
public:
|
||||
CardGui * getByCard(MTGCardInstance * card);
|
||||
MTGGuiPlay(int id, GameObserver * game);
|
||||
~MTGGuiPlay();
|
||||
void Update(float dt);
|
||||
void CheckUserInput(float dt);
|
||||
virtual void Render();
|
||||
void updateCards();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
120
projects/mtg/include/MTGRules.h
Normal file
120
projects/mtg/include/MTGRules.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* Default observers/Abilities that are added to the game for a standard Magic Game
|
||||
*/
|
||||
|
||||
#ifndef _MTGRULES_H_
|
||||
#define _MTGRULES_H_
|
||||
|
||||
#include "../include/MTGAbility.h"
|
||||
#include "../include/Counters.h"
|
||||
|
||||
|
||||
class MTGAttackRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
MTGAttackRule(int _id);
|
||||
const char * getMenuText(){return "Attacker";}
|
||||
|
||||
};
|
||||
|
||||
class MTGBlockRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
MTGBlockRule(int _id);
|
||||
const char * getMenuText(){return "Blocker";}
|
||||
};
|
||||
|
||||
|
||||
/* Persist Rule */
|
||||
class MTGPersistRule:public ListMaintainerAbility{
|
||||
public:
|
||||
MTGPersistRule(int _id):ListMaintainerAbility(_id){};
|
||||
|
||||
virtual void Update(float dt){
|
||||
map<MTGCardInstance *,bool>::iterator it;
|
||||
|
||||
for ( it=cards.begin() ; it != cards.end(); it++ ){
|
||||
MTGCardInstance * card = ((*it).first);
|
||||
Player * p = card->controller();
|
||||
if (p->game->graveyard->hasCard(card)){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("persist passed test 1 !\n");
|
||||
#endif
|
||||
p->game->putInZone(card, p->game->graveyard, p->game->hand);
|
||||
Spell * spell = NEW Spell(card);
|
||||
p->game->putInZone(card, p->game->hand, p->game->stack);
|
||||
spell->resolve();
|
||||
delete spell;
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("persist passed test 2 !\n");
|
||||
#endif
|
||||
card->counters->addCounter(-1,-1);
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("persist passed test 3 !\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ListMaintainerAbility::Update(dt);
|
||||
}
|
||||
|
||||
int canBeInList(MTGCardInstance * card){
|
||||
if (card->basicAbilities[PERSIST] && !card->counters->hasCounter(-1,-1) ){
|
||||
#if defined (WIN32) || defined (LINUX)
|
||||
OutputDebugString("yay, persist !\n");
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int added(MTGCardInstance * card){return 1;}
|
||||
|
||||
int removed(MTGCardInstance * card){return 0;}
|
||||
|
||||
int testDestroy(){return 0;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Rule 420.5e (Legend Rule)
|
||||
* If two or more legendary permanents with the same name are in play, all are put into their
|
||||
* owners' graveyards. This is called the "legend rule." If only one of those permanents is
|
||||
* legendary, this rule doesn't apply.
|
||||
*/
|
||||
class MTGLegendRule:public ListMaintainerAbility{
|
||||
public:
|
||||
MTGLegendRule(int _id):ListMaintainerAbility(_id){};
|
||||
|
||||
int canBeInList(MTGCardInstance * card){
|
||||
if (card->basicAbilities[LEGENDARY]){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int added(MTGCardInstance * card){
|
||||
map<MTGCardInstance *,bool>::iterator it;
|
||||
int destroy = 0;
|
||||
for ( it=cards.begin() ; it != cards.end(); it++ ){
|
||||
MTGCardInstance * comparison = (*it).first;
|
||||
if (comparison!= card && !strcmp(comparison->getName(), card->getName())){
|
||||
comparison->owner->game->putInGraveyard(comparison);
|
||||
destroy = 1;
|
||||
}
|
||||
}
|
||||
if (destroy){
|
||||
card->owner->game->putInGraveyard(card);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int removed(MTGCardInstance * card){return 0;}
|
||||
|
||||
int testDestroy(){return 0;}
|
||||
};
|
||||
|
||||
#endif
|
||||
44
projects/mtg/include/ManaCost.h
Normal file
44
projects/mtg/include/ManaCost.h
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifndef _MANACOST_H_
|
||||
#define _MANACOST_H_
|
||||
|
||||
#include "../include/utils.h"
|
||||
#include "../include/MTGDefinitions.h"
|
||||
|
||||
|
||||
class ManaCostHybrid;
|
||||
|
||||
class ManaCost{
|
||||
protected:
|
||||
int cost[MTG_NB_COLORS+1];
|
||||
ManaCostHybrid * hybrids[10];
|
||||
int nbhybrids;
|
||||
public:
|
||||
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL);
|
||||
void init();
|
||||
void x();
|
||||
ManaCost(int _cost[], int nb_elems);
|
||||
ManaCost();
|
||||
~ManaCost();
|
||||
ManaCost(ManaCost * _manaCost);
|
||||
void copy (ManaCost * _manaCost);
|
||||
int getConvertedCost();
|
||||
string toString();
|
||||
int getCost(int color);
|
||||
int getMainColor();
|
||||
int hasColor(int color);
|
||||
int remove (int color, int value);
|
||||
int add(int color, int value);
|
||||
int addHybrid(int c1, int v1, int c2, int v2);
|
||||
int tryToPayHybrids(ManaCostHybrid * _hybrids[], int _nbhybrids, int diff[]);
|
||||
void randomDiffHybrids(ManaCost * _cost, int diff[]);
|
||||
int add(ManaCost * _cost);
|
||||
int pay (ManaCost * _cost);
|
||||
|
||||
//return 1 if _cost can be paid with current data, 0 otherwise
|
||||
int canAfford(ManaCost * _cost);
|
||||
|
||||
int isPositive();
|
||||
ManaCost * Diff(ManaCost * _cost);
|
||||
};
|
||||
|
||||
#endif
|
||||
17
projects/mtg/include/ManaCostHybrid.h
Normal file
17
projects/mtg/include/ManaCostHybrid.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef _MANACOST_HYBRID_H_
|
||||
#define _MANACOST_HYBRID_H_
|
||||
|
||||
class ManaCostHybrid{
|
||||
public:
|
||||
int color1;
|
||||
int color2;
|
||||
int value1;
|
||||
int value2;
|
||||
ManaCostHybrid();
|
||||
int hasColor(int color);
|
||||
ManaCostHybrid(int c1,int v1,int c2,int v2);
|
||||
void init(int c1,int v1,int c2,int v2);
|
||||
int getConvertedCost();
|
||||
};
|
||||
|
||||
#endif
|
||||
43
projects/mtg/include/MenuItem.h
Normal file
43
projects/mtg/include/MenuItem.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef _MENU_ITEM_H
|
||||
#define _MENU_ITEM_H
|
||||
|
||||
#include <JLBFont.h>
|
||||
#include <JGui.h>
|
||||
#include <hge/hgeparticle.h>
|
||||
|
||||
#define SCALE_SELECTED 1.2f
|
||||
#define SCALE_NORMAL 1.0f
|
||||
|
||||
class hgeParticleSystem;
|
||||
|
||||
class MenuItem: public JGuiObject
|
||||
{
|
||||
private:
|
||||
bool mHasFocus;
|
||||
JLBFont *mFont;
|
||||
const char* const mText;
|
||||
int mX;
|
||||
int mY;
|
||||
int updatedSinceLastRender;
|
||||
float lastDt;
|
||||
|
||||
float mScale;
|
||||
float mTargetScale;
|
||||
JQuad * onQuad;
|
||||
JQuad * offQuad;
|
||||
hgeParticleSystem* mParticleSys;
|
||||
|
||||
|
||||
public:
|
||||
MenuItem(int id, JLBFont *font, const char* text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false);
|
||||
~MenuItem();
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
virtual void Entering();
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual bool ButtonPressed();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
40
projects/mtg/include/OptionItem.h
Normal file
40
projects/mtg/include/OptionItem.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef _OPTION_ITEM_H_
|
||||
#define _OPTION_ITEM_H_
|
||||
|
||||
#include <JGui.h>
|
||||
#include <string>
|
||||
|
||||
using std::string;
|
||||
|
||||
class OptionItem:public JGuiObject{
|
||||
public:
|
||||
string displayValue;
|
||||
int id, value;
|
||||
int hasFocus;
|
||||
int maxValue, increment;
|
||||
float x, y;
|
||||
OptionItem(int id, string _displayValue, int _maxValue = 1, int _increment = 1);
|
||||
|
||||
~OptionItem();
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
virtual void Entering();
|
||||
virtual bool Leaving();
|
||||
void setData();
|
||||
virtual void updateValue(){value+=increment; if (value>maxValue) value=0;};
|
||||
};
|
||||
|
||||
class OptionsList{
|
||||
public:
|
||||
OptionItem * options[20];
|
||||
int nbitems;
|
||||
int current;
|
||||
OptionsList();
|
||||
~OptionsList();
|
||||
void Render();
|
||||
void Update(float dt);
|
||||
void Add(OptionItem * item);
|
||||
void save();
|
||||
};
|
||||
|
||||
#endif
|
||||
78
projects/mtg/include/PlayGuiObject.h
Normal file
78
projects/mtg/include/PlayGuiObject.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
A class for all interactive objects in the play area (cards, avatars, etc...)
|
||||
*/
|
||||
|
||||
#ifndef _PLAYGUIOBJECT_H_
|
||||
#define _PLAYGUIOBJECT_H_
|
||||
|
||||
#define GUI_AVATAR 1
|
||||
#define GUI_CARD 2
|
||||
#define GUI_GRAVEYARD 3
|
||||
#define GUI_LIBRARY 4
|
||||
|
||||
#include <JGui.h>
|
||||
|
||||
class MTGGameZone;
|
||||
class Player;
|
||||
class CardDisplay;
|
||||
|
||||
class PlayGuiObject: public JGuiObject, public JGuiListener{
|
||||
protected:
|
||||
|
||||
public:
|
||||
int wave;
|
||||
float mHeight;
|
||||
float defaultHeight;
|
||||
bool mHasFocus;
|
||||
int x;
|
||||
int y;
|
||||
int type;
|
||||
virtual void Entering(){mHasFocus = true;};
|
||||
virtual bool Leaving(u32 key){mHasFocus = false;return true;};
|
||||
virtual bool ButtonPressed(){return true;};
|
||||
virtual void Render(){};
|
||||
virtual void Update(float dt);
|
||||
PlayGuiObject(int id, float desiredHeight,float _x, float _y, bool hasFocus);
|
||||
virtual void ButtonPressed(int controllerId, int controlId){};
|
||||
virtual ~PlayGuiObject(){};
|
||||
|
||||
};
|
||||
|
||||
class GuiAvatar: public PlayGuiObject{
|
||||
protected:
|
||||
|
||||
int avatarRed;
|
||||
int currentLife;
|
||||
public:
|
||||
Player * player;
|
||||
virtual void Render();
|
||||
GuiAvatar(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * _player);
|
||||
};
|
||||
|
||||
class GuiGameZone: public PlayGuiObject{
|
||||
protected:
|
||||
MTGGameZone * zone;
|
||||
|
||||
public:
|
||||
CardDisplay * cd;
|
||||
int showCards;
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
GuiGameZone(int id, float desiredHeight,float _x, float _y, bool hasFocus,MTGGameZone * _zone);
|
||||
~GuiGameZone();
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
void toggleDisplay();
|
||||
};
|
||||
|
||||
class GuiGraveyard: public GuiGameZone{
|
||||
public:
|
||||
GuiGraveyard(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player);
|
||||
};
|
||||
|
||||
class GuiLibrary: public GuiGameZone{
|
||||
public:
|
||||
GuiLibrary(int id, float desiredHeight,float _x, float _y, bool hasFocus,Player * player);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
21
projects/mtg/include/PlayGuiObjectController.h
Normal file
21
projects/mtg/include/PlayGuiObjectController.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _PLAYGUIOBJECTCONTROLLER_H_
|
||||
#define _PLAYGUIOBJECTCONTROLLER_H_
|
||||
|
||||
|
||||
#include "GuiLayers.h"
|
||||
|
||||
class PlayGuiObjectController : public GuiLayer{
|
||||
protected:
|
||||
int getClosestItem(int direction);
|
||||
int getClosestItem(int direction, float tolerance);
|
||||
static bool showBigCards;
|
||||
public:
|
||||
virtual void Update(float dt);
|
||||
virtual void CheckUserInput(float dt);
|
||||
PlayGuiObjectController(int id, GameObserver* _game):GuiLayer(id, _game){};
|
||||
virtual void Render(){GuiLayer::Render();};
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
50
projects/mtg/include/Player.h
Normal file
50
projects/mtg/include/Player.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef _PLAYER_H_
|
||||
#define _PLAYER_H_
|
||||
|
||||
#include <JGE.h>
|
||||
#include "ManaCost.h"
|
||||
#include "MTGGameZones.h"
|
||||
#include "Damage.h"
|
||||
#include "Targetable.h"
|
||||
|
||||
class MTGPlayerCards;
|
||||
class MTGInPlay;
|
||||
|
||||
class Player: public Damageable, public Targetable{
|
||||
protected:
|
||||
ManaCost * manaPool;
|
||||
|
||||
public:
|
||||
int typeAsTarget(){return TARGET_PLAYER;}
|
||||
virtual int displayStack(){return 1;}
|
||||
JTexture * mAvatarTex;
|
||||
JQuad * mAvatar;
|
||||
int canPutLandsIntoPlay;
|
||||
MTGPlayerCards * game;
|
||||
int testLife();
|
||||
int afterDamage();
|
||||
Player(MTGPlayerCards * _deck, char * deckFile);
|
||||
virtual ~Player();
|
||||
void unTapPhase();
|
||||
MTGInPlay * inPlay();
|
||||
ManaCost * getManaPool();
|
||||
int manaBurn();
|
||||
void cleanupPhase();
|
||||
virtual int Act(){return 0;};
|
||||
virtual int isAI(){return 0;};
|
||||
Player * opponent();
|
||||
int getId();
|
||||
JQuad * getIcon();
|
||||
string deckFile;
|
||||
};
|
||||
|
||||
class HumanPlayer: public Player{
|
||||
public:
|
||||
HumanPlayer(MTGPlayerCards * _deck, char * _deckFile);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
18
projects/mtg/include/PlayerData.h
Normal file
18
projects/mtg/include/PlayerData.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _PLAYER_DATA_H_
|
||||
#define _PLAYER_DATA_H_
|
||||
|
||||
#define PLAYER_SAVEFILE "Res/player/data.dat"
|
||||
|
||||
#include "../include/MTGDeck.h"
|
||||
|
||||
class PlayerData{
|
||||
protected:
|
||||
public:
|
||||
int credits;
|
||||
MTGDeck * collection;
|
||||
PlayerData(MTGAllCards * allcards);
|
||||
~PlayerData();
|
||||
int save();
|
||||
};
|
||||
|
||||
#endif
|
||||
31
projects/mtg/include/PriceList.h
Normal file
31
projects/mtg/include/PriceList.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#ifndef _PRICELIST_H_
|
||||
#define _PRICELIST_H_
|
||||
|
||||
#include<string>
|
||||
#include "../include/MTGDefinitions.h"
|
||||
#include "../include/MTGDeck.h"
|
||||
#include <stdio.h>
|
||||
|
||||
class Price{
|
||||
public:
|
||||
int cardid;
|
||||
int price;
|
||||
Price(int _cardid, int _price);
|
||||
};
|
||||
|
||||
class PriceList{
|
||||
private:
|
||||
MTGAllCards * collection;
|
||||
string filename;
|
||||
Price * prices[TOTAL_NUMBER_OF_CARDS];
|
||||
int nbprices;
|
||||
public:
|
||||
PriceList(const char * file, MTGAllCards * _collection);
|
||||
~PriceList();
|
||||
int save();
|
||||
int getPrice(int cardId);
|
||||
int setPrice(int cardId, int price);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
71
projects/mtg/include/ShopItem.h
Normal file
71
projects/mtg/include/ShopItem.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef _SHOP_ITEM_H
|
||||
#define _SHOP_ITEM_H
|
||||
|
||||
#include <JGui.h>
|
||||
#include <JLBFont.h>
|
||||
#include "SimpleMenu.h"
|
||||
#include "MTGDeck.h"
|
||||
#include "../include/PriceList.h"
|
||||
#include "../include/PlayerData.h"
|
||||
#include "../include/CardDisplay.h"
|
||||
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
class ShopItem:public JGuiObject{
|
||||
private:
|
||||
bool mHasFocus;
|
||||
JLBFont *mFont;
|
||||
string mText;
|
||||
int mX;
|
||||
int mY;
|
||||
JQuad * quad;
|
||||
JQuad * thumb;
|
||||
float mScale;
|
||||
float mTargetScale;
|
||||
|
||||
public:
|
||||
int quantity;
|
||||
MTGCard * card;
|
||||
int price;
|
||||
ShopItem(int id, JLBFont * font, int _cardid, int x, int y, bool hasFocus, MTGAllCards * collection, int _price);
|
||||
ShopItem(int id, JLBFont * font, char* text, JQuad * _quad, JQuad * _thumb,int x, int y, bool hasFocus, int _price);
|
||||
~ShopItem();
|
||||
|
||||
virtual void Render();
|
||||
virtual void Update(float dt);
|
||||
|
||||
virtual void Entering();
|
||||
virtual bool Leaving(u32 key);
|
||||
virtual bool ButtonPressed();
|
||||
|
||||
const char * getText();
|
||||
};
|
||||
|
||||
class ShopItems:public JGuiController,public JGuiListener{
|
||||
private:
|
||||
PlayerData * playerdata;
|
||||
PriceList * pricelist;
|
||||
int mX, mY, mHeight;
|
||||
JLBFont* mFont;
|
||||
MTGAllCards * collection;
|
||||
SimpleMenu * dialog;
|
||||
int showPriceDialog;
|
||||
int setId;
|
||||
MTGCardInstance * displayCards[100];
|
||||
CardDisplay * display;
|
||||
void safeDeleteDisplay();
|
||||
public:
|
||||
ShopItems(int id, JGuiListener* listener, JLBFont* font, int x, int y, MTGAllCards * _collection, int setId);
|
||||
~ShopItems();
|
||||
void Render();
|
||||
virtual void Update(float dt);
|
||||
void Add(int cardid);
|
||||
void Add(char * text, JQuad * quad, JQuad * thumb,int _price);
|
||||
void pricedialog(int id, int mode=1);
|
||||
virtual void ButtonPressed(int controllerId, int controlId);
|
||||
void savePriceList();
|
||||
void saveAll();
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user