Finally, all quest and duel decks fully encapsulated with acceptable format.

Helper files completely removed (easy.txt, quests.txt, etc.) and hard-coded quest properties are a thing of the past.

Model and view fully separated for main panel in quest GUI.

Critical file: QuestEventManager can handle instantiation of all decks, once (ideally).
This commit is contained in:
Doublestrike
2011-09-17 09:21:43 +00:00
parent 3e26b4b262
commit 6545bbf276
28 changed files with 1544 additions and 2478 deletions

22
.gitattributes vendored
View File

@@ -9399,13 +9399,9 @@ res/quest/decks/quest6.dck -text
res/quest/decks/quest7.dck -text
res/quest/decks/quest8.dck -text
res/quest/decks/quest9.dck -text
res/quest/easy.txt svneol=native#text/plain
res/quest/hard.txt svneol=native#text/plain
res/quest/medium.txt svneol=native#text/plain
res/quest/price.txt svneol=native#text/plain
res/quest/quest.preferences -text
res/quest/quest.properties svneol=native#text/plain
res/quest/quests.txt svneol=native#text/plain
res/quest/themes/-1[!!-~]-1[!!-~]Counters[!!-~]BG.thm -text
res/quest/themes/Anti[!!-~]Black[!!-~]WB.thm -text
res/quest/themes/Anti[!!-~]Black[!!-~]WG.thm -text
@@ -9474,7 +9470,6 @@ res/quest/themes/Vigilance[!!-~]Meekstone[!!-~]W.thm -text
res/quest/themes/White.thm -text
res/quest/themes/Wolves[!!-~]WG.thm -text
res/quest/themes/Zombies[!!-~]B.thm -text
res/quest/veryhard.txt svneol=native#text/plain
res/reprintSetInfo.py svneol=native#text/x-python
res/sealed/juzamjedi.zsealed -text
res/setInfoScript.py svneol=native#text/x-python
@@ -9583,8 +9578,6 @@ src/main/java/forge/PlayerType.java svneol=native#text/plain
src/main/java/forge/PlayerUtil.java svneol=native#text/plain
src/main/java/forge/PlayerZone.java svneol=native#text/plain
src/main/java/forge/PlayerZone_ComesIntoPlay.java svneol=native#text/plain
src/main/java/forge/Quest_Assignment.java svneol=native#text/plain
src/main/java/forge/ReadQuest_Assignment.java svneol=native#text/plain
src/main/java/forge/SetInfo.java svneol=native#text/plain
src/main/java/forge/SetUtils.java svneol=native#text/plain
src/main/java/forge/SimpleCombat.java svneol=native#text/plain
@@ -9768,7 +9761,7 @@ src/main/java/forge/game/limited/CardPoolLimitation.java -text
src/main/java/forge/game/limited/CustomLimited.java svneol=native#text/plain
src/main/java/forge/game/limited/DeckColors.java svneol=native#text/plain
src/main/java/forge/game/limited/SealedDeck.java svneol=native#text/plain
src/main/java/forge/game/limited/package-info.java -text svneol=native#text/plain
src/main/java/forge/game/limited/package-info.java svneol=native#text/plain
src/main/java/forge/game/package-info.java -text
src/main/java/forge/gui/CardListViewer.java -text
src/main/java/forge/gui/ForgeAction.java svneol=native#text/plain
@@ -9835,10 +9828,8 @@ src/main/java/forge/properties/NewConstants.java svneol=native#text/plain
src/main/java/forge/properties/Preferences.java svneol=native#text/plain
src/main/java/forge/properties/SavePreferencesListener.java svneol=native#text/plain
src/main/java/forge/properties/package-info.java svneol=native#text/plain
src/main/java/forge/quest/data/QuestBattleManager.java svneol=native#text/plain
src/main/java/forge/quest/data/QuestData.java svneol=native#text/plain
src/main/java/forge/quest/data/QuestDataIO.java svneol=native#text/plain
src/main/java/forge/quest/data/QuestEvent.java -text
src/main/java/forge/quest/data/QuestMatchState.java svneol=native#text/plain
src/main/java/forge/quest/data/QuestPreferences.java svneol=native#text/plain
src/main/java/forge/quest/data/QuestUtil.java svneol=native#text/plain
@@ -9869,15 +9860,19 @@ src/main/java/forge/quest/data/pet/QuestPetWolf.java svneol=native#text/plain
src/main/java/forge/quest/data/pet/package-info.java svneol=native#text/plain
src/main/java/forge/quest/gui/QuestAbstractPanel.java svneol=native#text/plain
src/main/java/forge/quest/gui/QuestFrame.java svneol=native#text/plain
src/main/java/forge/quest/gui/QuestMainPanel.java -text
src/main/java/forge/quest/gui/QuestOptions.java svneol=native#text/plain
src/main/java/forge/quest/gui/bazaar/QuestBazaarItem.java svneol=native#text/plain
src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java svneol=native#text/plain
src/main/java/forge/quest/gui/bazaar/QuestBazaarStall.java svneol=native#text/plain
src/main/java/forge/quest/gui/bazaar/package-info.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestBattle.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestMainPanel.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestDuel.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestDuelPanel.java -text
src/main/java/forge/quest/gui/main/QuestEvent.java -text
src/main/java/forge/quest/gui/main/QuestEventManager.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestQuest.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestSelectablePanel.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestQuestPanel.java -text
src/main/java/forge/quest/gui/main/QuestSelectablePanel.java -text
src/main/java/forge/quest/gui/main/package-info.java svneol=native#text/plain
src/main/java/forge/quest/gui/package-info.java svneol=native#text/plain
src/main/java/forge/quest/package-info.java svneol=native#text/plain
@@ -9937,7 +9932,6 @@ src/test/java/forge/GuiQuestOptionsTest.java svneol=native#text/plain
src/test/java/forge/GuiWinLoseTest.java svneol=native#text/plain
src/test/java/forge/PanelTest.java svneol=native#text/plain
src/test/java/forge/PhaseTest.java svneol=native#text/plain
src/test/java/forge/ReadQuestAssignmentTest.java svneol=native#text/plain
src/test/java/forge/RunTest.java svneol=native#text/plain
src/test/java/forge/TinyTest.java svneol=native#text/plain
src/test/java/forge/card/cardFactory/CardFactoryTest.java svneol=native#text/plain

View File

@@ -5,7 +5,7 @@ Text:no text
K:Flash
K:Enchant creature
A:SP$ Attach | Cost$ 1 W | ValidTgts$ Creature | AILogic$ Curse
S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddKeyword$ Shadow | AddHiddenKeyword$ HIDDEN Prevent all damage that would be dealt by CARDNAME. | Description$ Enchanted creature has shadow. Prevent all damage that would be dealt by enchanted creature.
S:Mode$ Continuous | Affected$ Creature.EnchantedBy | AddKeyword$ Shadow & HIDDEN Prevent all damage that would be dealt by CARDNAME. | Description$ Enchanted creature has shadow. Prevent all damage that would be dealt by enchanted creature.
SVar:Rarity:Common
SVar:Picture:http://www.wizards.com/global/images/magic/general/temporal_isolation.jpg
SetInfo:TSP|Common|http://magiccards.info/scans/en/ts/43.jpg

View File

@@ -1,55 +0,0 @@
Aquaman 1
Aragorn 1
Bamm Bamm Rubble 1
Barney Rubble 1
Bart Simpson 1
Buffy 1
C3PO 1
Catwoman 1
Conan the Barbarian 1
Cow 1
Crocodile Dundee 1
Da Vinci 1
Darrin Stephens 1
Dino 1
Doc Holiday 1
Elrond 1
Fat Albert 1
Fin Fang Foom 1
Frankenstein 1
Frodo 1
Galahad 1
Genghis Khan 1
George of the Jungle 1
Grampa Simpson 1
Green Arrow 1
Harry Potter 1
Hercules 1
Homer Simpson 1
Indiana Jones 1
Jack Sparrow 1
James Bond 1
Joe Kidd 1
Kang 1
King Arthur 1
King Edward 1
King Goldemar 1
King Kong 1
Kojak 1
Leprechaun 1
Magnum 1
Ned Flanders 1
Oberon 1
Odin 1
Princess Selenia 1
Rocky 1
Samantha Stephens 1
Seabiscuit 1
Sherlock Holmes 1
Shrek 1
Storm 1
Tarzan 1
Treebeard 1
Wilma Flintstone 1
White Knight 1
Wyatt Earp 1

View File

@@ -1,119 +0,0 @@
Abraham Lincoln 3
Albert Einstein 3
Alice in Wonderland 3
Aquaman 3
Atomic Robo 3
Barney Rubble 3
Bart Simpson 3
Batman 3
Bela Lugosi 3
Betty Rubble 3
Blackbeard 3
Boba Fett 3
Boris Karloff 3
Boromir 3
Bridge Troll 3
Buffy 3
C3PO 3
Captain America 3
Cave Troll 3
Comic Book Guy 3
Crocodile Dundee 3
Cyclops 3
Da Vinci 3
Darrin Stephens 3
Darth Vader 3
Data 3
Deadpool 3
Demon 3
Dilbert 3
Dino 3
Doc Holiday 3
Doran 3
Dream 3
Dr No 3
Dr Strangelove 3
Electro 3
Elrond 3
Endora 3
Ezio 3
Fat Albert 3
Fin Fang Foom 3
Frankenstein 3
Fred Flintstone 3
Frodo 3
Galahad 3
Genghis Khan 3
George of the Jungle 3
Gimli 3
Gold Finger 3
Grampa Simpson 3
Green Arrow 3
Green Lantern 3
Han Solo 3
Hans 3
Harry Potter 3
Hellboy 3
Hercules 3
Hermione Granger 3
Higgins 3
Hobbes 3
Homer Simpson 3
Iceman 3
Indiana Jones 3
Jabba the Hut 3
James Bond 3
James T Kirk 3
Joe Kidd 3
Kang 3
King Arthur 3
King Edward 3
King Kong 3
Kojak 3
Krypto 3
Luke Skywalker 3
Maggie Simpson 3
Magneto 3
Magnum 3
Mister Fantastic 3
Morpheus 3
Mr Slate 3
Napoleon 3
Ned Flanders 3
Neo 3
Newton 3
Oberon 3
Odin 3
Optimus Prime 3
Pebbles Flintstone 3
Picard 3
Pointy Haired Boss 3
Professor X 3
R2-D2 3
Radiant 3
Radioactive Man 3
Riddler 3
Rocky 3
Sabertooth 3
Samantha Stephens 3
Samwise Gamgee 3
Saruman 3
Scooby Doo 3
Scotty 3
Seabiscuit 3
Secret Squirrel 3
Sherlock Holmes 3
Silver Surfer 3
Spiderman 3
Storm 3
Superman 3
Terminator 3
The Great Gazoo 3
Tom Bombadil 3
Treebeard 3
Uncle Owen 3
Wally 3
White Knight 3
Wilma Flintstone 3
Wolverine 3
Wyatt Earp 3

View File

@@ -1,89 +0,0 @@
Albert Einstein 2
Alice in Wonderland 2
Apu Nahasapeemapetilon 2
Aquaman 2
Aragorn 2
Barney Rubble 2
Bart Simpson 2
Boromir 2
Buffy 2
C3PO 2
Captain America 2
Catwoman 2
Conan the Barbarian 2
Crocodile Dundee 2
Cyclops 2
Da Vinci 2
Darrin Stephens 2
Deadpool 2
Dino 2
Doc Holiday 2
Dogbert 2
Electro 2
Elrond 2
Endora 2
Eomer 2
Fat Albert 2
Fin Fang Foom 2
Frankenstein 2
Frodo 2
Galadriel 2
Galahad 2
Gambit 2
Genghis Khan 2
George of the Jungle 2
Gimli 2
Grampa Simpson 2
Green Arrow 2
Hagrid 2
Harry Potter 2
Hercules 2
Homer Simpson 2
Indiana Jones 2
Jack Sparrow 2
James Bond 2
Joe Kidd 2
Kang 2
King Arthur 2
King Edward 2
King Kong 2
Kojak 2
Krypto 2
Lisa Simpson 2
Magnum 2
Marge Simpson 2
Nagini 2
Ned Flanders 2
Neo 2
Oberon 2
Odin 2
Pebbles Flintstone 2
Pinky and the Brain 2
Professor X 2
Radagast 2
Ratbert 2
Redwall 2
Reverend Lovejoy 2
Rocky 2
Samantha Stephens 2
Samwise Gamgee 2
Saruman 2
Sauron 2
Scotty 2
Seabiscuit 2
Sherlock Holmes 2
Silver Samurai 2
Spiderman 2
Spock 2
Storm 2
Sun Quan 2
Swan 2
Tarzan 2
The Thing 2
Totoro 2
Treebeard 2
Walle 2
White Knight 2
Wilma Flintstone 2
Wonder Woman 2
Wyatt Earp 2

View File

@@ -1,315 +0,0 @@
Notes
- A [quest] line triggers a new quest object.
- Properties can be in any order
- IDs are mandatory, and must be sequential.
- Any other property, if empty, will use a default value.
- Both AI and human can have extra legal cards and/or tokens at match start.
[quest]
id=1
Icon=Dungeon Crawling White.jpg
Title=Dungeon Crawling (White)
Desc=This realm is guarded by a divine entity laying his protecting hand on each living being.
Diff=Medium
AILife=25
Repeat=true
Wins=20
Card Reward=3 white rares
Credit Reward=100
HumanExtras=
AIExtras=Divine Presence
[quest]
id=2
Icon=Dungeon Crawling Blue.jpg
Title=Dungeon Crawling (Blue)
Desc=This realm holds knowledge so vast it can overburden the unwary.
Diff=Medium
AILife=25
Repeat=true
Wins=20
Card Reward=3 blue rares
Credit Reward=100
HumanExtras=Quest for Ancient Secrets
AIExtras=Forced Fruition
[quest]
id=3
Icon=Dungeon Crawling Black.jpg
Title=Dungeon Crawling (Black)
Desc=The dead cannot be silenced, and want you to join their ranks.
Diff=Medium
AILife=25
Repeat=true
Wins=20
Card Reward=3 black rares
Credit Reward=100
HumanExtras=
AIExtras=Infernal Genesis
[quest]
id=4
Icon=Dungeon Crawling Red.jpg
Title=Dungeon Crawling (Red)
Desc=Untold treasure awaits you, should you successfully dodge the lightning and lava.
Diff=Medium
AILife=25
Repeat=true
Wins=20
Card Reward=3 red rares
Credit Reward=100
HumanExtras=
AIExtras=Furnace of Rath
[quest]
id=5
Icon=Dungeon Crawling Green.jpg
Title=Dungeon Crawling (Green)
Desc=Gnarled, twisting, sinister growths slowly rend the walls in twain and try to silence all who cross their path.
Diff=Medium
AILife=25
Repeat=true
Wins=20
Card Reward=3 green rares
Credit Reward=100
HumanExtras=Defense of the Heart
AIExtras=Eladamri's Vineyard|Upwelling
[quest]
id=6
Icon=Dungeon Crawling Colorless.jpg
Title=Dungeon Crawling (Colorless)
Desc=The inhabitants of this plane tread with a light step.
Diff=Hard
AILife=30
Repeat=true
Wins=28
Card Reward=3 colorless rares
Credit Reward=150
HumanExtras=
AIExtras=Eon Hub|Eon Hub|Eon Hub
[quest]
id=7
Icon=Dungeon Crawling Gold.jpg
Title=Dungeon Crawling (Gold)
Desc=Clever sorcerers draw energy from countless sources - can you outwit them?
Diff=Hard
AILife=30
Repeat=true
Wins=28
Card Reward=3 multi-colored rares
Credit Reward=150
HumanExtras=
AIExtras=Darksteel Ingot
[quest]
id=8
Icon=A Wolf in Sheeps Clothing.jpg
Title=A Wolf in Sheep's Clothing
Desc=The local sheep farm is under attack by a pack of wolves. Kill the wolves, save the sheep!
Diff=Medium
AILife=25
Repeat=false
Wins=28
Card Reward=3 random rares
Credit Reward=200
HumanExtras=TOKEN;G;0;1;Sheep;Creature;Sheep|TOKEN;G;0;1;Sheep;Creature;Sheep|TOKEN;G;0;1;Sheep;Creature;Sheep
AIExtras=
[quest]
id=9
Icon=Bushwhacked.jpg
Title=Bushwhacked!
Desc=You find yourself surrounded by carnivorous plants and poisonous vines. Cut your way out of this foresty mess and make it home safe.
Diff=Hard
AILife=30
Repeat=false
Wins=40
Card Reward=4 green rares
Credit Reward=225
HumanExtras=Trusty Machete
AIExtras=Wall of Wood|Wall of Wood|Wall of Wood
[quest]
id=10
Icon=Zombie Attack.jpg
Title=Zombie Attack!
Desc=The village of Haven is getting attacked by the Zombie horde! Protect the village.
Diff=Hard
AILife=30
Repeat=false
Wins=40
Card Reward=4 black rares
Credit Reward=200
HumanExtras=TOKEN;W;1;1;Citizen;Creature|TOKEN;W;1;1;Citizen;Creature|TOKEN;W;1;1;Citizen;Creature|Wall of Spears
AIExtras=Scathe Zombies|Mass of Ghouls
[quest]
id=11
Icon=The Kings Contest.jpg
Title=The King's Contest
Desc=The king is holding a contest. You are invited to participate and compete against other legends of this era.
Diff=Hard
AILife=30
Repeat=false
Wins=40
Card Reward=3 random rares
Credit Reward=150
HumanExtras=Seal of Cleansing
AIExtras=Loyal Retainers
[quest]
id=12
Icon=Barroom Brawl.jpg
Title=Barroom Brawl
Desc=A drunken giant of a man takes a swing at you, your brew spills and a fight breaks out.
Diff=Hard
AILife=30
Repeat=false
Wins=64
Card Reward=4 random rares
Credit Reward=250
HumanExtras=TOKEN;W;1;1;Soldier Ally;Creature;Soldier;Ally|TOKEN;W;1;1;Soldier Ally;Creature;Soldier;Ally|TOKEN;W;1;1;Soldier Ally;Creature;Soldier;Ally
AIExtras=Lowland Giant
[quest]
id=13
Icon=The Court Jester.jpg
Title=The Court Jester
Desc=The Court Jester pulls a prank on you. Will you laugh it off or pay him back?
Diff=Hard
AILife=30
Repeat=false
Wins=52
Card Reward=4 multi-colored rares
Credit Reward=300
HumanExtras=Sensei's Divining Top
AIExtras=Teferi's Puzzle Box
[quest]
id=14
Title=Ancient Battlefield
Desc=You visit an ancient battlefield at midnight. It is overgrown and dark. You trip on a root, utter a curse and wish that you could see.
Diff=Hard
AILife=30
Repeat=false
Wins=64
Card Reward=4 random rares
Credit Reward=250
Icon=Ancient Battlefield.jpg
HumanExtras=Glasses of Urza|Blight Sickle
AIExtras=Bad Moon|Wall of Brambles
[quest]
id=15
Title=Don't Play With Matches
Desc=The goblins are battling the elves. Those pesky elves, will they ever learn. Do not play with fire!
Diff=Hard
AILife=30
Repeat=false
Wins=52
Card Reward=4 red rares
Credit Reward=200
Icon=Dont Play With Matches.jpg
HumanExtras=Mudbutton Torchrunner|Scuzzback Scrapper
AIExtras=Heedless One|Norwood Archers|Wildslayer Elves
[quest]
id=16
Title=Mines of Kazum Durl
Desc=While exploring a mine with a group of dwarves the mine caves in. You start to dig out and then realize that your group is not alone.
Diff=Hard
AILife=30
Repeat=false
Wins=52
Card Reward=4 green rares
Credit Reward=250
Icon=Mines of Kazum Durl.jpg
HumanExtras=Dwarven Demolition Team|Dwarven Pony|Dwarven Trader
AIExtras=Wall of Earth|Wall of Air|Wall of Ice|Wall of Light|Carrion Wall|Steel Wall
[quest]
id=17
Title=House Party
Desc=Your friends decide to hold a house party at your home tonight. Later that night uninvited guests show up and disrupt the party.
Diff=Hard
AILife=30
Repeat=false
Wins=64
Card Reward=4 colorless rares
Credit Reward=250
Icon=House Party.jpg
HumanExtras=Hopping Automaton|Honden of Life's Web|Forbidden Orchard
AIExtras=Honden of Infinite Rage|Mikokoro, Center of the Sea
[quest]
id=18
Title=Crows in the Field
Desc=Crows are eating the seed planted in the local farm fields. The farmers are scared. Those crows are big, you will need some help.
Diff=Hard
AILife=30
Repeat=false
Wins=64
Card Reward=5 random rares
Credit Reward=300
Icon=Crows in the Field.jpg
HumanExtras=Straw Soldiers|Femeref Archers|Moonglove Extract
AIExtras=Defiant Falcon|Soulcatcher|Storm Crow|Hypnotic Specter
[quest]
id=19
Title=The Desert Caravan
Desc=A caravan is transporting silk across the desert. While setting up camp for the night you are attacked by thieves. Defend yourself.
Diff=Hard
AILife=30
Repeat=false
Wins=80
Card Reward=5 random rares
Credit Reward=300
Icon=The Desert Caravan.jpg
HumanExtras=Spidersilk Net|Dromad Purebred
AIExtras=Ambush Party|Ambush Party|Ambush Party|Ambush Party|Gnat Alley Creeper
[quest]
id=20
Title=Blood Oath
Desc=A druid saves your life and the two of you take a blood oath. It is now time to fulfill your oath.
Diff=Hard
AILife=30
Repeat=false
Wins=80
Card Reward=5 colorless rares
Credit Reward=300
Icon=Blood Oath.jpg
HumanExtras=Counterbalance|Hatching Plans|Ley Druid
AIExtras=Ior Ruin Expedition|Oversold Cemetery|Trapjaw Kelpie
[quest]
id=21
Title=Private Domain
Desc=During your travels, you accidentally stumble upon the domain of an evil, powerful wizard. A fight to the death ensues.
Diff=Expert
AILife=50
Repeat=false
Wins=96
Card Reward=6 random rares
Credit Reward=500
Icon=Private Domain.jpg
HumanExtras=Strip Mine
AIExtras=Plains|Island|Mountain|Swamp|Forest
[quest]
id=22
Title=The Pied Piper
Desc=A mysterious man threatens to flood the land with a relentless stream of hungry rats. Cross his plan before it's too late.
Diff=Hard
AILife=30
Repeat=false
Wins=32
Card Reward=3 random rares
Credit Reward=150
Icon=The Pied Piper.jpg
HumanExtras=Volunteer Militia|Land Tax|Elvish Farmer|An-Havva Township
AIExtras=Darksteel Citadel|Relentless Rats

View File

@@ -1,9 +0,0 @@
Boromir 4
Darrin Stephens 4
Dino 4
Gold Finger 4
Hobbes 4
Ned Flanders 4
Radioactive Man 4
Riddler 4
Samantha Stephens 4

View File

@@ -17,6 +17,7 @@ import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestData;
import forge.quest.gui.main.QuestQuest;
/**
* Please use public getters and setters instead of direct field access.
@@ -42,7 +43,7 @@ public final class AllZone implements NewConstants {
private static forge.quest.data.QuestData questData = null;
/** Global <code>QuestAssignment</code>. */
private static Quest_Assignment questAssignment = null;
private static QuestQuest questquest = null;
/** Constant <code>NAME_CHANGER</code>. */
private static final NameChanger NAME_CHANGER = new NameChanger();
@@ -136,8 +137,8 @@ public final class AllZone implements NewConstants {
* @return a {@link forge.Quest_Assignment} object.
* @since 1.0.15
*/
public static Quest_Assignment getQuestAssignment() {
return questAssignment;
public static QuestQuest getQuestQuest() {
return questquest;
}
/**
@@ -146,8 +147,8 @@ public final class AllZone implements NewConstants {
* @param assignment a {@link forge.Quest_Assignment} object.
* @since 1.0.15
*/
public static void setQuestAssignment(final Quest_Assignment assignment) {
questAssignment = assignment;
public static void setQuestQuest(final QuestQuest q) {
questquest = q;
}
/**

View File

@@ -29,6 +29,7 @@ import forge.gui.input.Input_PayManaCost_Ability;
import forge.item.CardPrinted;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.LANG.GameAction.GAMEACTION_TEXT;
import forge.quest.gui.main.QuestQuest;
import java.util.ArrayList;
import java.util.Comparator;
@@ -653,7 +654,7 @@ public class GameAction {
AllZone.getDisplay().savePrefs();
frame.setEnabled(false);
//frame.dispose();
Gui_WinLose gwl = new Gui_WinLose(AllZone.getMatchState(), AllZone.getQuestData(), AllZone.getQuestAssignment());
Gui_WinLose gwl = new Gui_WinLose(AllZone.getMatchState(), AllZone.getQuestData(), AllZone.getQuestQuest());
//gwl.setAlwaysOnTop(true);
gwl.toFront();
canShowWinLose = false;
@@ -1074,15 +1075,15 @@ public class GameAction {
* @param computer a {@link forge.CardList} object.
*/
public final void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
final CardList computer, final int humanLife, final int computerLife, final Quest_Assignment qa)
final CardList computer, final int humanLife, final int computerLife, final QuestQuest qq)
{
this.newGame(humanDeck, computerDeck);
AllZone.getComputerPlayer().setLife(computerLife, null);
AllZone.getHumanPlayer().setLife(humanLife, null);
if (qa != null) {
computer.addAll(forge.quest.data.QuestUtil.getComputerStartingCards(AllZone.getQuestData(), AllZone.getQuestAssignment()));
if (qq != null) {
computer.addAll(forge.quest.data.QuestUtil.getComputerStartingCards(AllZone.getQuestData(), AllZone.getQuestQuest()));
}
for (Card c : human) {

View File

@@ -17,6 +17,7 @@ import forge.quest.data.QuestData;
import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestPreferences;
import forge.quest.gui.QuestFrame;
import forge.quest.gui.main.QuestQuest;
import forge.view.swing.OldGuiNewGame;
import net.miginfocom.swing.MigLayout;
@@ -65,7 +66,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
private class WinLoseModel {
public QuestMatchState match;
public QuestData quest;
public Quest_Assignment qa;
public QuestQuest qq;
}
private WinLoseModel model;
@@ -77,11 +78,11 @@ public class Gui_WinLose extends JFrame implements NewConstants {
* @param quest a QuestData object
* @param qa a Quest_Assignment object
*/
public Gui_WinLose(final QuestMatchState matchState, final QuestData quest, final Quest_Assignment qa) {
public Gui_WinLose(final QuestMatchState matchState, final QuestData quest, final QuestQuest qq) {
model = new WinLoseModel();
model.match = matchState;
model.quest = quest;
model.qa = qa;
model.qq = qq;
try {
jbInit();
@@ -186,25 +187,25 @@ public class Gui_WinLose extends JFrame implements NewConstants {
void prepareForNextRound() {
if (Constant.Quest.fantasyQuest[0]) {
int extraLife = 0;
if (model.qa != null) {
if (model.qq != null) {
if (model.quest.getInventory().hasItem("Zeppelin")) {
extraLife = 3;
}
}
//AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0],
//humanList, computerList, humanLife, computerLife);
CardList humanList = forge.quest.data.QuestUtil.getHumanStartingCards(model.quest, model.qa);
CardList humanList = forge.quest.data.QuestUtil.getHumanStartingCards(model.quest, model.qq);
CardList computerList = new CardList();
int humanLife = model.quest.getLife() + extraLife;
int computerLife = 20;
if (model.qa != null) {
computerLife = model.qa.getComputerLife();
if (model.qq != null) {
computerLife = model.qq.getAILife();
}
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0],
humanList, computerList, humanLife, computerLife, model.qa);
humanList, computerList, humanLife, computerLife, model.qq);
} else {
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]);
}
@@ -362,7 +363,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
giveQuestRewards(wonMatch);
model.match.reset();
AllZone.setQuestAssignment(null);
AllZone.setQuestQuest(null);
model.quest.saveData();
@@ -440,11 +441,11 @@ public class Gui_WinLose extends JFrame implements NewConstants {
}
// Rewards from QuestAssignment
if (wonMatch && model.qa != null) {
if (wonMatch && model.qq != null) {
model.quest.addQuestsPlayed();
List<CardPrinted> questRewardCards = model.qa.getCardRewardList();
long questRewardCredits = model.qa.getCreditsReward();
List<CardPrinted> questRewardCards = model.qq.getCardRewardList();
long questRewardCredits = model.qq.getCreditsReward();
StringBuilder sb = new StringBuilder();
sb.append("Quest Completed - \r\n");
@@ -465,7 +466,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
String fileName = "BoxIcon.png";
ImageIcon icon = getIcon(fileName);
String title = "Quest Rewards for " + model.qa.getName();
String title = "Quest Rewards for " + model.qq.getTitle();
JOptionPane.showMessageDialog(null, sb.toString(), title, JOptionPane.INFORMATION_MESSAGE, icon);
}
/*

View File

@@ -1,289 +0,0 @@
package forge;
import java.util.ArrayList;
import java.util.List;
import forge.item.CardPrinted;
/**
* <p>Quest_Assignment class.</p>
* An instance of a single quest assignment. Holds values that aren't defined in
* Deck class, such as credit reward.
*
* @author Forge
* @version $Id$
*/
public class Quest_Assignment {
// ID (default -1, should be explicitly set at later time.)
private int id = -1;
// Default vals if none provided for this ID in quests.txt.
private int requiredNumberWins = 20;
private int computerLife = 25;
private long creditsReward = 100;
private String name = "Mystery Quest";
private String desc = "";
private String difficulty = "Medium";
private String cardReward = "1 colorless rare";
private String iconName = "Unknown.jpg";
private boolean repeatable = false;
// Other cards used in assignment: starting, and reward.
private CardList humanExtraCards = new CardList();
private CardList aiExtraCards = new CardList();
private List<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
// No constructor required; fields are set dynamically.
// Setters and getters, in alphabetical order.
/**
* <p>Setter for the field <code>aiExtraCards</code>.</p>
* Sets list of cards automatically played at start of match.
*
* @param s a CardList object.
*/
public final void setAIExtraCards(final CardList cl) {
this.aiExtraCards = cl;
}
/**
* <p>Getter for the field <code>aiExtraCards</code>.</p>
* Gets list of cards automatically played at start of match.
*
* @return a {@link java.util.ArrayList} object.
*/
public final CardList getAIExtraCards() {
return aiExtraCards;
}
/**
* <p>Setter for the field <code>cardReward</code>.</p>
* Sets string notated card reward received if match is won.
*
* @param cardRewardIn a {@link java.lang.String} object.
*/
public final void setCardReward(final String cardRewardIn) {
this.cardReward = cardRewardIn;
}
/**
* <p>Getter for the field <code>cardReward</code>.</p>
* Gets string notated card reward received if match is won.
*
* @return a {@link java.lang.String} object.
*/
public final String getCardReward() {
return cardReward;
}
/**
* <p>Setter for the field <code>cardRewardList</code>.</p>
* Sets card reward list for cards received if match is won.
*
* @return a {@link java.util.ArrayList} object.
*/
public void setCardRewardList(final List<CardPrinted> cp) {
this.cardRewardList = cp;
}
/**
* <p>Getter for the field <code>cardRewardList</code>.</p>
* Gets card reward list for cards received if match is won.
*
* @return a {@link java.util.ArrayList} object.
*/
public final List<CardPrinted> getCardRewardList() {
return cardRewardList;
}
/**
* <p>Setter for the field <code>computerLife</code>.</p>
* Sets computer life at start of match.
*
* @param computerLifeIn a int.
*/
public final void setComputerLife(final int computerLifeIn) {
this.computerLife = computerLifeIn;
}
/**
* <p>Getter for the field <code>computerLife</code>.</p>
* Gets computer life at start of match.
*
* @return a int.
*/
public final int getComputerLife() {
return computerLife;
}
/**
* <p>Setter for the field <code>creditsReward</code>.</p>
* Sets credit reward received if match is won.
*
* @param creditsRewardIn a long.
*/
public final void setCreditsReward(final long creditsRewardIn) {
this.creditsReward = creditsRewardIn;
}
/**
* <p>Getter for the field <code>creditsReward</code>.</p>
* Gets credit reward received if match is won.
*
* @return a long.
*/
public final long getCreditsReward() {
return creditsReward;
}
/**
* <p>Setter for the field <code>desc</code>.</p>
*
* @param descIn a {@link java.lang.String} object.
*/
public final void setDesc(final String descIn) {
this.desc = descIn;
}
/**
* <p>Getter for the field <code>desc</code>.</p>
*
* @return a {@link java.lang.String} object.
*/
public final String getDesc() {
return desc;
}
/**
* <p>Setter for the field <code>difficulty</code>.</p>
*
* @param difficultyIn a {@link java.lang.String} object.
*/
public final void setDifficulty(final String difficultyIn) {
this.difficulty = difficultyIn;
}
/**
* <p>Setter for the field <code>humanExtraCards</code>.</p>
* Sets list of cards automatically played at start of match.
*
* @param s a CardList object.
*/
public final void setHumanExtraCards(final CardList cl) {
this.humanExtraCards = cl;
}
/**
* <p>Getter for the field <code>humanExtraCards</code>.</p>
* Gets list of cards automatically played at start of match.
*
* @return a {@link forge.CardList} object.
*/
public final CardList getHumanExtraCards() {
return humanExtraCards;
}
/**
* <p>Getter for the field <code>difficulty</code>.</p>
*
* @return a {@link java.lang.String} object.
*/
public final String getDifficulty() {
return difficulty;
}
/**
* <p>Setter for the field <code>id</code>.</p>
*
* @param idIn a int.
*/
public final void setId(final int idIn) {
this.id = idIn;
}
/**
* <p>Getter for the field <code>id</code>.</p>
*
* @return a int.
*/
public final int getId() {
return id;
}
/**
* <p>Setter for the field <code>iconName</code>.</p>
* Sets filename of icon used when displaying this quest.
*
* @param s a {@link java.lang.String} object.
*/
public final void setIconName(final String s) {
iconName = s;
}
/**
* <p>Getter for the field <code>iconName</code>.</p>
* Gets filename of icon used when displaying this quest.
*
* @return a {@link java.lang.String} object.
*/
public final String getIconName() {
return iconName;
}
/**
* <p>Setter for the field <code>name</code>.</p>
*
* @param nameIn a {@link java.lang.String} object.
*/
public final void setName(final String nameIn) {
this.name = nameIn;
}
/**
* <p>Getter for the field <code>name</code>.</p>
*
* @return a {@link java.lang.String} object.
*/
public final String getName() {
return name;
}
/**
* <p>Setter for the field <code>repeatable</code>.</p>
*
* @param repeatableIn a boolean.
*/
public final void setRepeatable(final boolean repeatableIn) {
this.repeatable = repeatableIn;
}
/**
* <p>isRepeatable.</p>
*
* @return a boolean.
*/
public final boolean isRepeatable() {
return repeatable;
}
/**
* <p>Setter for the field <code>requiredNumberWins</code>.</p>
* Sets number of wins required to unlock this quest.
*
* @param requiredNumberWinsIn a int.
*/
public final void setRequiredNumberWins(final int requiredNumberWinsIn) {
this.requiredNumberWins = requiredNumberWinsIn;
}
/**
* <p>Getter for the field <code>requiredNumberWins</code>.</p>
* Gets number of wins required to unlock this quest.
*
* @return a int.
*/
public final int getRequiredNumberWins() {
return requiredNumberWins;
}
}

View File

@@ -1,278 +0,0 @@
package forge;
import forge.error.ErrorViewer;
import forge.properties.NewConstants;
import forge.quest.data.QuestUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* <p>ReadQuest_Assignment class.</p>
*
* @author Forge
* @version $Id$
*/
public class ReadQuest_Assignment implements Runnable, NewConstants {
ArrayList<Quest_Assignment> allQuests = new ArrayList<Quest_Assignment>();
private ArrayList<Integer> ids = new ArrayList<Integer>();
private BufferedReader br;
private int totalWins;
private List<Integer> completedQuests = new ArrayList<Integer>();
// Constants, tied to properties in the quests.txt file.
private static final String ID = "id";
private static final String ICON = "Icon";
private static final String TITLE = "Title";
private static final String DESC = "Desc";
private static final String DIFF = "Diff";
private static final String AILIFE = "AILife";
private static final String REPEAT = "Repeat";
private static final String WINS = "Wins";
private static final String CARDS = "Card Reward";
private static final String CREDITS = "Credit Reward";
private static final String HUMANEXTRAS = "HumanExtras";
private static final String AIEXTRAS = "AIExtras";
/**
* <p>Constructor for ReadQuest_Assignment.</p>
* Sets parameters for available quests and prepares buffered reader for quests.txt.
*
* @param filename a {@link java.lang.String} object.
* @param questData a {@link forge.quest.data.QuestData} object.
*/
public ReadQuest_Assignment(String filename, forge.quest.data.QuestData questData) {
this(new File(filename), questData);
}
/**
* <p>Constructor for ReadQuest_Assignment.</p>
* Sets parameters for available quests and prepares buffered reader for quests.txt.
*
* @param file a {@link java.io.File} object.
* @param questData a {@link forge.quest.data.QuestData} object.
*/
public ReadQuest_Assignment(File file, forge.quest.data.QuestData questData) {
if (questData != null) {
totalWins = questData.getWin();
if (questData.getCompletedQuests() != null) {
completedQuests = questData.getCompletedQuests();
}
else {
completedQuests = new ArrayList<Integer>();
}
}
try {
br = new BufferedReader(new FileReader(file));
} catch (Exception ex) {
ErrorViewer.showError(ex, "File \"%s\" not found", file.getAbsolutePath());
throw new RuntimeException("ReadQuest_Assignment > constructor error: "+
"BufferedReader failed, '"+file.getAbsolutePath()+"' not found.");
}
} // ReadQuest_Assignment()
/**
* <p>getAvailableQuests.</p>
* Returns list of currently available quest objects.
*
* @return a {@link java.util.List} object.
*/
public List<Quest_Assignment> getAvailableQuests() {
ArrayList<Quest_Assignment> availableQuests = new ArrayList<Quest_Assignment>();
for(Quest_Assignment qa : allQuests) {
if (qa.getRequiredNumberWins() <= totalWins && !completedQuests.contains(qa.getId())) {
availableQuests.add(qa);
}
}
return availableQuests;
}
/**
* <p>getQuests.</p>
* Returns complete list of all quest objects.
*
* @return a {@link java.util.List} object.
*/
public List<Quest_Assignment> getAllQuests() {
return allQuests;
}
/**
* <p>getQuestsByIds.</p>
*
* @param availableQuestIds a {@link java.util.List} object.
* @return a {@link java.util.List} object.
*/
public List<Quest_Assignment> getQuestsByIds(List<Integer> availableQuestIds) {
List<Quest_Assignment> q = new ArrayList<Quest_Assignment>();
for (Quest_Assignment qa : allQuests) {
if (availableQuestIds.contains(qa.getId())) {
q.add(qa);
}
}
return q;
}
/**
* <p>getQuestById.</p>
*
* @param i a int.
* @return a {@link forge.Quest_Assignment} object.
*/
public Quest_Assignment getQuestById(int id) {
// Error handling for OOB ID?
return allQuests.get(id);
}
/**
* <p>run.</p>
* Assembles Quest_Assignment instances into allQuests.
*/
public void run() {
Quest_Assignment qa = null;
String line;
int i;
String[] linedata;
try {
while ((line = br.readLine()) != null) {
if(line.equals("[quest]")) {
qa = new Quest_Assignment();
allQuests.add(qa);
}
else if(!line.equals("") && qa != null) {
linedata = line.split("=", 2);
linedata[1] = linedata[1].trim();
// If empty data, ignore the line (assignment will use default).
if(linedata[1].equals("")) {
continue;
}
// Data OK.
if(linedata[0].equals(ID)) {
i = Integer.parseInt(linedata[1]);
// Duplicate ID check
if(ids.contains(i)) {
throw new RuntimeException("ReadQuest_Assignment > run() error: duplicate quest ID ("+i+")");
}
// Non-sequential ID check
else if(i != allQuests.size()) {
throw new RuntimeException("ReadQuest_Assignment > run() error: non-sequential quest ID ("+i+")");
}
// ID OK.
else {
ids.add(i);
qa.setId(i);
}
}
else if(linedata[0].equals(ICON)) {
qa.setIconName(linedata[1]);
}
else if(linedata[0].equals(TITLE)) {
qa.setName(linedata[1]);
}
else if(linedata[0].equals(DESC)) {
qa.setDesc(linedata[1]);
}
else if(linedata[0].equals(DIFF)) {
qa.setDifficulty(linedata[1]);
}
else if(linedata[0].equals(REPEAT)) {
qa.setRepeatable(Boolean.parseBoolean(linedata[1]));
}
else if(linedata[0].equals(AILIFE)) {
qa.setComputerLife(Integer.parseInt(linedata[1]));
}
else if(linedata[0].equals(WINS)) {
qa.setRequiredNumberWins(Integer.parseInt(linedata[1]));
}
else if(linedata[0].equals(CREDITS)) {
qa.setCreditsReward(Integer.parseInt(linedata[1]));
}
// Card reward list assembled here.
else if(linedata[0].equals(CARDS)) {
qa.setCardReward(linedata[1]);
qa.setCardRewardList(QuestUtil.generateCardRewardList(linedata[1]));
}
// Human extra card list assembled here.
else if(linedata[0].equals(HUMANEXTRAS)) {
String[] names = linedata[1].split("\\|");
CardList templist = new CardList();
Card tempcard;
for(String s : names) {
// Token card creation
if(s.substring(0,5).equals("TOKEN")) {
tempcard = QuestUtil.createToken(s);
tempcard.addController(AllZone.getHumanPlayer());
tempcard.setOwner(AllZone.getHumanPlayer());
templist.add(tempcard);
}
// Standard card creation
else {
tempcard = AllZone.getCardFactory().getCard(s, AllZone.getHumanPlayer());
tempcard.setCurSetCode(tempcard.getMostRecentSet());
tempcard.setImageFilename(CardUtil.buildFilename(tempcard));
templist.add(tempcard);
}
}
qa.setHumanExtraCards(templist);
}
// AI extra card list assembled here.
else if(linedata[0].equals(AIEXTRAS)) {
String[] names = linedata[1].split("\\|");
CardList templist = new CardList();
Card tempcard;
for(String s : names) {
// Token card creation
if(s.substring(0,5).equals("TOKEN")) {
tempcard = QuestUtil.createToken(s);
tempcard.addController(AllZone.getComputerPlayer());
tempcard.setOwner(AllZone.getComputerPlayer());
templist.add(tempcard);
}
// Standard card creation
else {
tempcard = AllZone.getCardFactory().getCard(s, AllZone.getComputerPlayer());
tempcard.setCurSetCode(tempcard.getMostRecentSet());
tempcard.setImageFilename(CardUtil.buildFilename(tempcard));
templist.add(tempcard);
}
}
qa.setAIExtraCards(templist);
}
} // else if()
} // while()
br.close();
}
catch (IOException e) {
e.printStackTrace();
}
// Confirm that all quests have IDs.
for(Quest_Assignment q : allQuests) {
if(q.getId()==-1) {
throw new RuntimeException("ReadQuest_Assignment > getQuests() error: "+
"Quest ID missing for '"+q.getName()+"'.");
}
}
} // run()
}

View File

@@ -53,7 +53,7 @@ public final class BoosterUtils {
int nRares = numRare, nMythics = 0;
Predicate<CardPrinted> filterMythics = Predicate.and(filter, CardPrinted.Predicates.Presets.isMythicRare);
boolean haveMythics = filterMythics.any(cardpool);
boolean haveMythics = false;//filterMythics.any(cardpool);
for(int iSlot = 0; haveMythics && iSlot < numRare; iSlot++) {
if (MyRandom.random.nextInt(7) < 1) { // a bit higher chance to get a mythic
nRares--;

View File

@@ -1,194 +0,0 @@
package forge.quest.data;
import forge.AllZone;
import forge.FileUtil;
import forge.deck.Deck;
import forge.deck.DeckManager;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import java.io.File;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
/**
* <p>QuestBattleManager class.</p>
*
* @author Forge
* @version $Id$
*/
public class QuestBattleManager {
/** Constant <code>easyAIDecks</code> */
private static transient List<String> easyAIDecks;
/** Constant <code>mediumAIDecks</code> */
private static transient List<String> mediumAIDecks;
/** Constant <code>hardAIDecks</code> */
private static transient List<String> hardAIDecks;
/** Constant <code>veryHardAIDecks</code> */
private static transient List<String> veryHardAIDecks;
static {
easyAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.EASY));
mediumAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.MEDIUM));
hardAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.HARD));
veryHardAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.VERYHARD));
}
/**
* <p>getOpponent.</p>
*
* Badly named; AllZoneUtil already has a method called getOpponents.
* ?????
*
* @param aiDeck a {@link java.util.List} object.
* @param number a int.
* @return a {@link java.lang.String} object.
*/
public static String getOpponent(List<String> aiDeck, int number) {
//This is to make sure that the opponents do not change when the deck editor is launched.
List<String> deckListCopy = new ArrayList<String>(aiDeck);
Collections.shuffle(deckListCopy, new Random(AllZone.getQuestData().getRandomSeed()));
return deckListCopy.get(number);
}
/**
* <p>generateBattles.</p>
* Generates an array of new opponents based on current win conditions.
*
* @return an array of {@link java.lang.String} objects.
*/
public static String[] generateBattles() {
int index = AllZone.getQuestData().getDifficultyIndex();
if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForMediumAI(index)) {
return new String[]{
getOpponent(easyAIDecks, 0),
getOpponent(easyAIDecks, 1),
getOpponent(easyAIDecks, 2)};
}
if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForMediumAI(index)) {
return new String[]{
getOpponent(easyAIDecks, 0),
getOpponent(mediumAIDecks, 0),
getOpponent(mediumAIDecks, 1)};
}
if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForHardAI(index)) {
return new String[]{
getOpponent(mediumAIDecks, 0),
getOpponent(mediumAIDecks, 1),
getOpponent(mediumAIDecks, 2)};
}
if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForHardAI(index)) {
return new String[]{
getOpponent(mediumAIDecks, 0),
getOpponent(hardAIDecks, 0),
getOpponent(hardAIDecks, 1)};
}
if (AllZone.getQuestData().getWin() >= QuestPreferences.getWinsForVeryHardAI(index)) {
return new String[]{
getOpponent(hardAIDecks, 0),
getOpponent(hardAIDecks, 1),
getOpponent(veryHardAIDecks, 0)};
}
return new String[]{
getOpponent(hardAIDecks, 0),
getOpponent(hardAIDecks, 1),
getOpponent(hardAIDecks, 2)};
}
/**
* <p>getDeckFromFile.</p>
* Returns a deck object built from a file name.
*
* @param deckName a {@link java.lang.String} object.
* @return a {@link forge.deck.Deck} object.
*/
public static Deck getAIDeckFromFile(String deckName) {
final File file = ForgeProps.getFile(NewConstants.QUEST.DECKS);
final DeckManager manager = new DeckManager(file);
return manager.getDeck(deckName);
}
/**
* <p>getQuestEventFromFile.</p>
* Returns QuestEvent data for the challenge stored in that file name.
*
* @param deckName a {@link java.lang.String} object.
* @return a {@link forge.deck.Deck} object.
*/
public static QuestEvent getQuestEventFromFile(String deckName) {
final File deckPath = ForgeProps.getFile(NewConstants.QUEST.DECKS);
File deckFile = new File(deckPath, deckName + ".dck");
QuestEvent result = readQuestBattleMetadataFromDeckFile(deckFile);
return result;
}
/**
* <p>readFile.</p>
* A reader util for accessing the AI deck list text files.
*
* @param file a {@link java.io.File} object.
* @param aiDecks a {@link java.util.List} object.
* @return a {@link java.util.List} object.
*/
private static List<String> readFile(File file) {
ArrayList<String> list = FileUtil.readFile(file);
//remove any blank lines
ArrayList<String> noBlankLines = new ArrayList<String>();
String s;
for (String aList : list) {
s = aList.trim();
if (!s.equals("")) {
noBlankLines.add(s);
}
}
list = noBlankLines;
if (list.size() < 3) {
ErrorViewer.showError(new Exception(),
"QuestData : readFile() error, file %s is too short, it must contain at least 3 ai deck names",
file);
}
return list;
}
private static QuestEvent readQuestBattleMetadataFromDeckFile(final File f) {
QuestEvent out = new QuestEvent();
List<String> contents = FileUtil.readFile(f);
for (String s : contents) {
if ("[main]".equals(s)) { break; }
if (StringUtils.isBlank(s) || s.charAt(0) == '[') { continue; }
int eqPos = s.indexOf('=');
if (eqPos < 0) { continue; } // no equals sign here
String key = s.substring(0, eqPos);
String value = s.substring(eqPos + 1);
if ("DisplayName".equalsIgnoreCase(key)) {
out.displayName = value;
} else if ("Difficulty".equalsIgnoreCase(key)) {
out.difficulty = value;
} else if ("Description".equalsIgnoreCase(key)) {
out.description = value;
} else if ("Icon".equalsIgnoreCase(key)) {
out.icon = value;
}
}
return out;
}
}

View File

@@ -1,17 +0,0 @@
package forge.quest.data;
/**
* TODO: Write javadoc for this type.
*
*/
public class QuestEvent {
String displayName;
String difficulty;
String description;
String icon;
public final String getDisplayName() { return displayName; }
public final String getDifficulty() { return difficulty; }
public final String getDescription() { return description; }
public final String getIcon() { return icon; }
}

View File

@@ -3,21 +3,21 @@ package forge.quest.data;
import forge.Card;
import forge.CardList;
import forge.Constant;
import forge.Quest_Assignment;
import forge.card.CardRarity;
import forge.card.BoosterUtils;
import forge.item.CardPrinted;
import forge.quest.gui.main.QuestQuest;
import java.util.List;
/**
* <p>QuestUtil class.</p>
* MODEL - Static utility methods to help with minor tasks around Quest.
*
* @author Forge
* @version $Id$
*/
public class QuestUtil {
/**
* <p>getComputerStartingCards.</p>
*
@@ -36,11 +36,11 @@ public class QuestUtil {
* @param qa a {@link forge.Quest_Assignment} object.
* @return a {@link forge.CardList} object.
*/
public static CardList getComputerStartingCards(final QuestData qd, Quest_Assignment qa) {
public static CardList getComputerStartingCards(final QuestData qd, QuestQuest qq) {
CardList list = new CardList();
if (qa != null) {
list.addAll(qa.getAIExtraCards());
if (qq != null) {
list.addAll(qq.getAIExtraCards());
}
return list;
}
@@ -75,11 +75,11 @@ public class QuestUtil {
* @param qa a {@link forge.Quest_Assignment} object.
* @return a {@link forge.CardList} object.
*/
public static CardList getHumanStartingCards(final QuestData qd, Quest_Assignment qa) {
public static CardList getHumanStartingCards(final QuestData qd, QuestQuest qq) {
CardList list = getHumanStartingCards(qd);
if (qa != null) {
list.addAll(qa.getHumanExtraCards());
if (qq != null) {
list.addAll(qq.getHumanExtraCards());
}
return list;
@@ -164,16 +164,4 @@ public class QuestUtil {
return BoosterUtils.generateCards(qty, rar, col);
}
/**
* <p>setupQuest.</p>
* Assembled hard-coded quest options.
* All non-deck-specific handling now takes place in quests.txt.
*
* @deprecated
* @param qa
*/
public static void setupQuest(Quest_Assignment qa) {
}
} //QuestUtil

View File

@@ -3,7 +3,7 @@ package forge.quest.gui;
import forge.AllZone;
import forge.gui.GuiUtils;
import forge.quest.gui.bazaar.QuestBazaarPanel;
import forge.quest.gui.main.QuestMainPanel;
import forge.quest.gui.main.QuestEventManager;
import forge.view.swing.OldGuiNewGame;
import javax.swing.*;
@@ -24,6 +24,7 @@ public class QuestFrame extends JFrame {
JPanel visiblePanel;
CardLayout questLayout;
QuestEventManager qem = new QuestEventManager();
/** Constant <code>MAIN_PANEL="Main"</code> */
public static final String MAIN_PANEL = "Main";
@@ -39,6 +40,13 @@ public class QuestFrame extends JFrame {
*/
public QuestFrame() throws HeadlessException {
this.setTitle("Quest Mode");
// DOUBLESTRIKE SEZ - this assembles all events, once.
// Unfortunately, QuestFrame is called several times.
// This is THE WRONG PLACE for this method, feel free to move,
// I'll do it very soon anyways, this is only a temporary thing.
if(qem.getAllDuels()==null) {
qem.assembleAllEvents();
}
visiblePanel = new JPanel(new BorderLayout());
visiblePanel.setBorder(new EmptyBorder(2, 2, 2, 2));
@@ -53,7 +61,6 @@ public class QuestFrame extends JFrame {
visiblePanel.add(newPanel, BAZAAR_PANEL);
subPanelMap.put(BAZAAR_PANEL, newPanel);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(visiblePanel, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(1024, 768));

View File

@@ -1,4 +1,4 @@
package forge.quest.gui.main;
package forge.quest.gui;
import forge.*;
@@ -6,11 +6,13 @@ import forge.deck.Deck;
import forge.gui.GuiUtils;
import forge.gui.deckeditor.DeckEditorShop;
import forge.gui.deckeditor.DeckEditorQuest;
import forge.quest.data.QuestBattleManager;
import forge.quest.data.QuestData;
import forge.quest.data.item.QuestItemZeppelin;
import forge.quest.gui.QuestAbstractPanel;
import forge.quest.gui.QuestFrame;
import forge.quest.gui.main.QuestDuel;
import forge.quest.gui.main.QuestDuelPanel;
import forge.quest.gui.main.QuestQuest;
import forge.quest.gui.main.QuestQuestPanel;
import forge.quest.gui.main.QuestSelectablePanel;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@@ -27,9 +29,10 @@ import java.util.List;
/**
* <p>QuestMainPanel class.</p>
* VIEW - lays out swing components for duel and quest events.
*
* @author Forge
* @version $Id$
* @version $Id: QuestMainPanel.java 10358 2011-09-11 05:20:13Z Doublestrike $
*/
public class QuestMainPanel extends QuestAbstractPanel {
/** Constant <code>serialVersionUID=6142934729724012402L</code> */
@@ -75,6 +78,11 @@ public class QuestMainPanel extends QuestAbstractPanel {
GuiUtils.getResizedIcon(GuiUtils.getIconFromFile("ZeppelinIcon.png"), 40, 40));
private JPanel zeppelinPanel = new JPanel();
//TODO: DOUBLESTRIKE SEZ - the event manager is currently linked to
// the QuestFrame. There is almost definitely a better way to do that.
// I'll be fixing it very soon, after this core commit is up and working.
QuestFrame TEST = null;
/**
* <p>Constructor for QuestMainPanel.</p>
*
@@ -84,6 +92,8 @@ public class QuestMainPanel extends QuestAbstractPanel {
super(mainFrame);
questData = AllZone.getQuestData();
TEST = mainFrame;
initUI();
}
@@ -379,51 +389,57 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>createBattlePanel.</p>
* <p>createDuelPanel.</p>
* Makes a parent panel, then selectable panel instances for all available duels.
*
* @return a {@link javax.swing.JPanel} object.
*/
private JPanel createBattlePanel() {
JPanel BattlePanel = new JPanel();
BattlePanel.setLayout(new BoxLayout(BattlePanel, BoxLayout.Y_AXIS));
BattlePanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Battles"));
private JPanel createDuelPanel() {
JPanel DuelPanel = new JPanel();
QuestDuelPanel duelEvent;
DuelPanel.setLayout(new BoxLayout(DuelPanel, BoxLayout.Y_AXIS));
DuelPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Battles"));
List<QuestSelectablePanel> Battles = QuestBattle.getBattles();
List<QuestDuel> duels = TEST.qem.generateDuels();
for (QuestSelectablePanel Battle : Battles) {
BattlePanel.add(Battle);
Battle.addMouseListener(new SelectionAdapter(Battle));
for (QuestDuel qd : duels) {
duelEvent = new QuestDuelPanel(qd);
DuelPanel.add(duelEvent);
duelEvent.addMouseListener(new SelectionAdapter(duelEvent));
GuiUtils.addGap(BattlePanel, 3);
GuiUtils.addGap(DuelPanel, 3);
}
BattlePanel.setAlignmentX(LEFT_ALIGNMENT);
DuelPanel.setAlignmentX(LEFT_ALIGNMENT);
return BattlePanel;
return DuelPanel;
}
/**
* <p>createQuestPanel.</p>
* Makes a parent panel, then selectable panel instances for all available battles.
*
* @return a {@link javax.swing.JPanel} object.
*/
private JPanel createQuestPanel() {
JPanel questPanel = new JPanel();
questPanel.setLayout(new BoxLayout(questPanel, BoxLayout.Y_AXIS));
questPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Quests"));
JPanel QuestPanel = new JPanel();
QuestSelectablePanel selpan;
QuestPanel.setLayout(new BoxLayout(QuestPanel, BoxLayout.Y_AXIS));
QuestPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Quests"));
List<QuestQuest> quests = QuestQuest.getQuests();
List<QuestQuest> quests = TEST.qem.generateQuests();
for (QuestQuest quest : quests) {
questPanel.add(quest);
quest.addMouseListener(new SelectionAdapter(quest));
for (QuestQuest qq : quests) {
selpan = new QuestQuestPanel(qq);
QuestPanel.add(selpan);
selpan.addMouseListener(new SelectionAdapter(selpan));
GuiUtils.addGap(questPanel, 3);
GuiUtils.addGap(QuestPanel, 3);
}
return questPanel;
return QuestPanel;
}
/**
@@ -538,7 +554,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
nextMatchPanel.removeAll();
nextMatchLayout = new CardLayout();
nextMatchPanel.setLayout(nextMatchLayout);
nextMatchPanel.add(createBattlePanel(), BATTLES);
nextMatchPanel.add(createDuelPanel(), BATTLES);
nextMatchPanel.add(createQuestPanel(), QUESTS);
if (isShowingQuests) {
this.nextMatchLayout.show(nextMatchPanel, QUESTS);
@@ -632,7 +648,6 @@ public class QuestMainPanel extends QuestAbstractPanel {
* <p>launchGame.</p>
*/
private void launchGame() {
//TODO: This is a temporary hack to see if the image cache affects the heap usage significantly.
ImageCache.clear();
@@ -641,11 +656,13 @@ public class QuestMainPanel extends QuestAbstractPanel {
questData.randomizeOpponents();
String humanDeckName = (String) deckComboBox.getSelectedItem();
Deck humanDeck = questData.getDeck(humanDeckName);
Constant.Runtime.HumanDeck[0] = humanDeck;
moveDeckToTop(humanDeckName);
Constant.Quest.oppIconName[0] = getMatchIcon();
Constant.Quest.oppIconName[0] = getEventIconFilename();
// Dev Mode occurs before Display
Constant.Runtime.DevMode[0] = devModeCheckBox.isSelected();
@@ -665,7 +682,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
if (isShowingQuests) {
setupQuest(humanDeck);
} else {
setupBattle(humanDeck);
setupDuel(humanDeck);
}
AllZone.getQuestData().saveData();
@@ -676,13 +693,12 @@ public class QuestMainPanel extends QuestAbstractPanel {
/**
* <p>setupBattle.</p>
* <p>setupDuel.</p>
*
* @param humanDeck a {@link forge.deck.Deck} object.
*/
void setupBattle(Deck humanDeck) {
Deck computer = QuestBattleManager.getAIDeckFromFile((selectedOpponent).getName());
void setupDuel(Deck humanDeck) {
Deck computer = selectedOpponent.getEvent().getEventDeck();
Constant.Runtime.ComputerDeck[0] = computer;
AllZone.getGameAction().newGame(humanDeck, computer, forge.quest.data.QuestUtil.getHumanStartingCards(questData),
@@ -695,12 +711,12 @@ public class QuestMainPanel extends QuestAbstractPanel {
* @param humanDeck a {@link forge.deck.Deck} object.
*/
private void setupQuest(Deck humanDeck) {
Quest_Assignment selectedQuest = ((QuestQuest) selectedOpponent).getQuestAssignment();
QuestQuest selectedQuest = (QuestQuest)selectedOpponent.getEvent();
Deck computerDeck = QuestBattleManager.getAIDeckFromFile("quest" + selectedQuest.getId());
Constant.Runtime.ComputerDeck[0] = computerDeck;
Deck computer = selectedOpponent.getEvent().getEventDeck();
Constant.Runtime.ComputerDeck[0] = computer;
AllZone.setQuestAssignment(selectedQuest);
AllZone.setQuestQuest(selectedQuest);
int extraLife = 0;
@@ -708,28 +724,19 @@ public class QuestMainPanel extends QuestAbstractPanel {
extraLife = 3;
}
AllZone.getGameAction().newGame(humanDeck, computerDeck,
AllZone.getGameAction().newGame(humanDeck, computer,
forge.quest.data.QuestUtil.getHumanStartingCards(questData, selectedQuest), new CardList(),
questData.getLife() + extraLife, selectedQuest.getComputerLife(), selectedQuest);
questData.getLife() + extraLife, selectedQuest.getAILife(), selectedQuest);
}
/**
* <p>getMatchIcon.</p>
* <p>getEventIconFilename.</p>
*
* @return a {@link java.lang.String} object.
*/
String getMatchIcon() {
String oppIconName;
if (isShowingQuests) {
Quest_Assignment selectedQuest = ((QuestQuest) selectedOpponent).getQuestAssignment();
oppIconName = selectedQuest.getIconName();
} else {
oppIconName = selectedOpponent.getName();
oppIconName = oppIconName.substring(0, oppIconName.length() - 1).trim() + ".jpg";
}
return oppIconName;
private String getEventIconFilename() {
return selectedOpponent.getIconFilename();
}
/**

View File

@@ -1,90 +0,0 @@
package forge.quest.gui.main;
import forge.gui.GuiUtils;
import forge.quest.data.QuestBattleManager;
import forge.quest.data.QuestEvent;
import javax.swing.*;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* <p>QuestBattle class.</p>
* Manages QuestSelectablePanel instances for "battle" style matches.
*
* @author Forge
* @version $Id$
*/
public class QuestBattle extends QuestSelectablePanel {
/** Constant <code>serialVersionUID=3112668476017792084L</code> */
private static final long serialVersionUID = 3112668476017792084L;
private String deckName;
/**
* <p>Constructor for QuestBattle.</p>
*
* @param name a {@link java.lang.String}, stores display name of opponent.
* @param diff a {@link java.lang.String} stores difficulty of opponent.
* @param description a {@link java.lang.String} stores description of opponent's deck.
* @param icon a {@link javax.swing.ImageIcon} stores opponent's icon.
*/
private QuestBattle(String name, String deck, String diff, String desc, ImageIcon icon) {
super(name, diff, desc, icon);
this.deckName = deck;
}
/**
* <p>getBattles.</p>
*
* Returns list of QuestBattle objects storing data
* of the battles currently available.
*
* @return a {@link java.util.List} object.
*/
// There's got to be a better place for this method.
public static List<QuestSelectablePanel> getBattles() {
List<QuestSelectablePanel> opponentList = new ArrayList<QuestSelectablePanel>();
String[] oppDecks = QuestBattleManager.generateBattles();
for (String oppDeckName : oppDecks) {
// Get deck object and properties for this opponent.
QuestEvent event1 = QuestBattleManager.getQuestEventFromFile(oppDeckName);
String oppName = event1.getDisplayName();
String oppDiff = event1.getDifficulty();
String oppDesc = event1.getDescription();
String oppIconAddress = event1.getIcon();
ImageIcon icon;
// If non-default icon defined, use it
if (StringUtils.isBlank(oppIconAddress)) {
icon = GuiUtils.getIconFromFile(oppName + ".jpg");
}
else
icon = GuiUtils.getIconFromFile(oppIconAddress + ".jpg");
// Add to list of current quest opponents.
opponentList.add(
new QuestBattle(oppName, oppDeckName, oppDiff, oppDesc, icon)
);
}
return opponentList;
}
/** {@inheritDoc} */
@Override
public String getName() {
// Called by ???? to get deck name for image icon generation.
// Exception should be thrown somewhere if image can't be found.
return deckName;
}
}

View File

@@ -0,0 +1,12 @@
package forge.quest.gui.main;
/**
* <p>QuestDuel class.</p>
* MODEL - A single duel event data instance, including meta and deck.
*
*/
public class QuestDuel extends QuestEvent {
// [QuestDuel has no unique properties yet.]
}

View File

@@ -0,0 +1,20 @@
package forge.quest.gui.main;
/**
* <p>QuestDuelPanel.</p>
* VIEW - Creates a QuestSelectablePanel instance for a "battle" style event.
*/
@SuppressWarnings("serial")
public class QuestDuelPanel extends QuestSelectablePanel {
/** <p>QuestDuelPanel.</p>
* Constructor, using duel data instance.
*
* @param {@link forge.quest.gui.main.QuestDuel}
*/
public QuestDuelPanel(QuestDuel d) {
super(d);
}
}

View File

@@ -0,0 +1,73 @@
package forge.quest.gui.main;
import forge.deck.Deck;
/**
* <p>QuestEvent.</p>
*
* MODEL - A basic event instance in Quest mode. Can be extended for use in
* unique event types: battles, quests, and others.
*/
public class QuestEvent {
// Default vals if none provided in the event file.
public Deck eventDeck = null;
public String title = "Mystery Event";
public String description = "";
public String difficulty = "Medium";
public String icon = "Unknown.jpg";
public String name = "Noname";
/**
* <p>getTitle.</p>
*
* @return a {@link java.lang.String}.
*/
public final String getTitle() {
return title;
}
/**
* <p>getDifficulty.</p>
*
* @return a {@link java.lang.String}.
*/
public final String getDifficulty() {
return difficulty;
}
/**
* <p>getDescription.</p>
*
* @return a {@link java.lang.String}.
*/
public final String getDescription() {
return description;
}
/**
* <p>getEventDeck.</p>
*
* @return {@link forge.deck.Deck}
*/
public final Deck getEventDeck() {
return eventDeck;
}
/**
* <p>getIcon.</p>
*
* @return a {@link java.lang.String}.
*/
public final String getIcon() {
return icon;
}
/**
* <p>getName.</p>
*
* @return a {@link java.lang.String}.
*/
public final String getName() {
return name;
}
}

View File

@@ -0,0 +1,406 @@
package forge.quest.gui.main;
import forge.AllZone;
import forge.Card;
import forge.CardList;
import forge.CardUtil;
import forge.FileUtil;
import forge.deck.DeckManager;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.quest.data.QuestPreferences;
import forge.quest.data.QuestUtil;
import java.io.File;
import java.util.*;
/**
* <p>QuestEventManager.</p>
* MODEL - Manages collections of quest events (duelsquests, etc.)
*
* @author Forge
* @version $Id$
*/
public class QuestEventManager {
public List<QuestDuel> easyAIduels = null;
public List<QuestDuel> mediumAIduels = null;
public List<QuestDuel> hardAIduels = null;
public List<QuestDuel> veryHardAIduels = null;
public List<QuestDuel> allDuels = null;
public List<QuestQuest> allQuests = null;
/**<p>assembleAllEvents.</p> *
* Reads all quest and battle files to extract quest data.
* Instantiates all duel and quest events, and difficulty lists accordingly.
* Should be used sparingly.
*/
public void assembleAllEvents() {
this.allDuels = new ArrayList<QuestDuel>();
this.allQuests = new ArrayList<QuestQuest>();
List<String> contents;
QuestEvent tempEvent;
File file = ForgeProps.getFile(NewConstants.QUEST.DECKS);
DeckManager manager = new DeckManager(file);
File[] allFiles = ForgeProps.getFile(NewConstants.QUEST.DECKS).listFiles();
for(File f : allFiles) {
contents = FileUtil.readFile(f);
if(contents.get(0).trim().equals("[quest]")) {
tempEvent = new QuestQuest();
assembleQuestUniquedata(contents,(QuestQuest)tempEvent);
allQuests.add((QuestQuest)tempEvent);
} // End if([quest])
else {
tempEvent = new QuestDuel();
assembleDuelUniquedata(contents,(QuestDuel)tempEvent);
allDuels.add((QuestDuel)tempEvent);
}
// Assemble metadata (may not be necessary later) and deck object.
assembleEventMetadata(contents,tempEvent);
tempEvent.eventDeck = manager.getDeck(tempEvent.getName());
} // End for(allFiles)
assembleDuelDifficultyLists();
} // End assembleAllEvents()
/**
* <p>assembleDuelUniqueData.</p>
* Handler for any unique data contained in duel files.
*
* @param contents
* @param qd
*/
private void assembleDuelUniquedata(List<String> contents, QuestDuel qd) {
int eqpos;
String key, value;
for(String s : contents) {
if (s.equals("[metadata]")) { break; }
if (s.equals("[duel]")) { continue; }
if (s.equals("")) { continue; }
eqpos = s.indexOf('=');
key = s.substring(0, eqpos);
value = s.substring(eqpos + 1);
if (key.equalsIgnoreCase("Name")) {
qd.name = value;
}
}
}
/**
* <p>assembleQuestUniquedata.</p>
* Handler for any unique data contained in quest files.
*
* @param contents
* @param qq
*/
private void assembleQuestUniquedata(List<String> contents, QuestQuest qq) {
int eqpos;
String key, value;
// Unique properties
for(String s : contents) {
if (s.equals("[metadata]")) { break; }
if (s.equals("[quest]")) { continue; }
if (s.equals("")) { continue; }
eqpos = s.indexOf('=');
key = s.substring(0, eqpos);
value = s.substring(eqpos + 1).trim();
if (key.equalsIgnoreCase("ID")) {
qq.id = Integer.parseInt(value);
}
else if (key.equalsIgnoreCase("Repeat")) {
qq.repeatable = Boolean.parseBoolean(value);
}
else if (key.equalsIgnoreCase("AILife")) {
qq.aiLife = Integer.parseInt(value);
}
else if (key.equalsIgnoreCase("Wins")) {
qq.winsReqd = Integer.parseInt(value);
}
else if (key.equalsIgnoreCase("Credit Reward")) {
qq.creditsReward = Integer.parseInt(value);
}
else if (key.equalsIgnoreCase("Card Reward")) {
qq.cardReward = value;
qq.cardRewardList = QuestUtil.generateCardRewardList(value);
}
// Human extra card list assembled here.
else if(key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
String[] names = value.split("\\|");
CardList templist = new CardList();
Card tempcard;
for(String n : names) {
// Token card creation
if(n.substring(0,5).equals("TOKEN")) {
tempcard = QuestUtil.createToken(n);
tempcard.addController(AllZone.getHumanPlayer());
tempcard.setOwner(AllZone.getHumanPlayer());
templist.add(tempcard);
}
// Standard card creation
else {
tempcard = AllZone.getCardFactory().getCard(n, AllZone.getHumanPlayer());
tempcard.setCurSetCode(tempcard.getMostRecentSet());
tempcard.setImageFilename(CardUtil.buildFilename(tempcard));
templist.add(tempcard);
}
}
qq.humanExtraCards = templist;
}
// AI extra card list assembled here.
else if(key.equalsIgnoreCase("AIExtras") && !value.equals("")) {
String[] names = value.split("\\|");
CardList templist = new CardList();
Card tempcard;
for(String n : names) {
// Token card creation
if(n.substring(0,5).equals("TOKEN")) {
tempcard = QuestUtil.createToken(n);
tempcard.addController(AllZone.getComputerPlayer());
tempcard.setOwner(AllZone.getComputerPlayer());
templist.add(tempcard);
}
// Standard card creation
else {
tempcard = AllZone.getCardFactory().getCard(n, AllZone.getComputerPlayer());
tempcard.setCurSetCode(tempcard.getMostRecentSet());
tempcard.setImageFilename(CardUtil.buildFilename(tempcard));
templist.add(tempcard);
}
}
qq.aiExtraCards = templist;
}
// Card reward list assembled here.
else if(key.equalsIgnoreCase("Card Reward")) {
qq.cardReward = value;
qq.cardRewardList = QuestUtil.generateCardRewardList(value);
}
}
}
/**
* <p>assembleEventMetadata.</p>
* Handler for metadata contained in event files.
*
* @param contents
* @param qe
*/
private void assembleEventMetadata(List<String> contents, QuestEvent qe) {
int eqpos;
String key, value;
for(String s : contents) {
s = s.trim();
eqpos = s.indexOf('=');
if (s.equals("[main]")) { break; }
if (s.equals("[metadata]")) { continue; }
if (s.equals("")) { continue; }
if (eqpos==-1) { continue; }
key = s.substring(0, eqpos);
value = s.substring(eqpos + 1);
if (key.equalsIgnoreCase("Name")) {
qe.name = value;
}
else if (key.equalsIgnoreCase("Title")) {
qe.title = value;
}
else if (key.equalsIgnoreCase("Difficulty")) {
qe.difficulty = value;
}
else if (key.equalsIgnoreCase("Description")) {
qe.description = value;
}
else if (key.equalsIgnoreCase("Icon")) {
qe.icon = value;
}
}
}
/**
* <p>getAllDuels.</p>
* Returns complete list of all duel objects.
*
* @return a {@link java.util.List} object.
*/
public List<QuestDuel> getAllDuels() {
return this.allDuels;
}
/**
* <p>getAllQuests.</p>
* Returns complete list of all quest objects.
*
* @return a {@link java.util.List} object.
*/
public List<QuestQuest> getAllQuests() {
return this.allQuests;
}
/**
* <p>assembleDuelDifficultyLists.</p>
* Assemble duel deck difficulty lists
*/
private void assembleDuelDifficultyLists() {
easyAIduels = new ArrayList<QuestDuel>();
mediumAIduels = new ArrayList<QuestDuel>();
hardAIduels = new ArrayList<QuestDuel>();
veryHardAIduels = new ArrayList<QuestDuel>();
String s;
for(QuestDuel qd : allDuels) {
s = qd.getDifficulty();
if(s.equalsIgnoreCase("easy")) {
easyAIduels.add(qd);
}
else if(s.equalsIgnoreCase("medium")) {
mediumAIduels.add(qd);
}
else if(s.equalsIgnoreCase("hard")) {
hardAIduels.add(qd);
}
else if(s.equalsIgnoreCase("very hard")) {
veryHardAIduels.add(qd);
}
}
}
/**
* <p>getDuelOpponent.</p>
* Returns specific duel opponent from current shuffle of available duels.
* This is to make sure that the opponents do not change
* when the deck editor is launched.
*
* @param aiDeck a {@link java.util.List} object.
* @param number a int.
* @return a {@link java.lang.String} object.
*/
private static QuestDuel getDuelOpponentByNumber(List<QuestDuel> aiDeck, int n) {
List<QuestDuel> deckListCopy = new ArrayList<QuestDuel>(aiDeck);
Collections.shuffle(deckListCopy, new Random(AllZone.getQuestData().getRandomSeed()));
return deckListCopy.get(n);
}
private QuestQuest getQuestOpponentByNumber(int n) {
for(QuestQuest qq : allQuests) {
if(qq.getId()==n) {
return qq;
}
}
return null;
}
/**
* <p>generateDuels.</p>
* Generates an array of new duel opponents based on current win conditions.
*
* @return an array of {@link java.lang.String} objects.
*/
public List<QuestDuel> generateDuels() {
int index = AllZone.getQuestData().getDifficultyIndex();
List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>();
if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForMediumAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 1));
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 2));
}
else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForMediumAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 1));
}
else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForHardAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 1));
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 2));
}
else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForHardAI(index)) {
duelOpponents.add( getDuelOpponentByNumber(mediumAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1));
}
else if (AllZone.getQuestData().getWin() >= QuestPreferences.getWinsForVeryHardAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1));
duelOpponents.add(getDuelOpponentByNumber(veryHardAIduels, 0));
}
else {
duelOpponents.add(getDuelOpponentByNumber(veryHardAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(veryHardAIduels, 1));
duelOpponents.add(getDuelOpponentByNumber(veryHardAIduels, 2));
}
return duelOpponents;
}
/**
* <p>generateQuests.</p>
* Generates an array of new quest opponents based on current win conditions.
*
* @return a {@link java.util.List} object.
*/
public List<QuestQuest> generateQuests() {
forge.quest.data.QuestData questData = AllZone.getQuestData();
List<QuestQuest> questOpponents = new ArrayList<QuestQuest>();
// If no quests available right now, generate new IDs.
if (questData.getAvailableQuests() == null || questData.getAvailableQuests().size() == 0) {
// Assemble full list of currently available IDs.
List<Integer> availableQuestIds = new ArrayList<Integer>();
for(QuestQuest qq : allQuests) {
if (qq.getWinsReqd() <= questData.getWin() &&
!questData.getCompletedQuests().contains(qq.getId())) {
availableQuestIds.add(qq.getId());
}
}
// Filter that list as needed.
int maxQuests = questData.getWin() / 10;
if (maxQuests > 5) {
maxQuests = 5;
}
Collections.shuffle(availableQuestIds);
for (int i = 0; i < maxQuests; i++) {
availableQuestIds.add(i);
}
questData.setAvailableQuests(availableQuestIds);
questData.saveData();
} //
// Finally, pull quest events from available IDs and return.
for(int i : questData.getAvailableQuests()) {
questOpponents.add(getQuestOpponentByNumber(i));
}
return questOpponents;
}
}

View File

@@ -1,116 +1,114 @@
package forge.quest.gui.main;
import forge.AllZone;
import forge.Quest_Assignment;
import forge.ReadQuest_Assignment;
import forge.gui.GuiUtils;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.CardList;
import forge.item.CardPrinted;
import javax.swing.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* <p>QuestQuest class.</p>
*
* Manages QuestSelectablePanel instances for "quest" style matches.
* MODEL - A single quest event data instance, including meta,
* deck, and quest-specific properties.
*
* @author Forge
* @version $Id$
*/
public class QuestQuest extends QuestSelectablePanel {
/** Constant <code>serialVersionUID=-162817410327650160L</code> */
private static final long serialVersionUID = -162817410327650160L;
public class QuestQuest extends QuestEvent {
// ID (default -1, should be explicitly set at later time.)
public int id = -1;
Quest_Assignment assignment;
// Default vals if none provided for this ID
public int aiLife = 25;
public int creditsReward = 100;
public String cardReward = "1 colorless rare";
public boolean repeatable = false;
public int winsReqd = 20;
// Other cards used in assignment: starting, and reward.
public CardList humanExtraCards = new CardList();
public CardList aiExtraCards = new CardList();
public List<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
/**
* <p>Constructor for QuestQuest.</p>
* <p>getAILife.</p>
*
* @param assignment a {@link forge.Quest_Assignment} object.
* @return {@link java.lang.Integer}.
*/
public QuestQuest(Quest_Assignment assignment) {
super(assignment.getName(), assignment.getDifficulty(), assignment.getDesc(), GuiUtils.getIconFromFile(assignment.getIconName()));
this.assignment = assignment;
JLabel repeatabilityLabel;
if (assignment.isRepeatable()) {
repeatabilityLabel = new JLabel("This quest is repeatable");
} else {
repeatabilityLabel = new JLabel("This quest is not repeatable");
}
GuiUtils.addGap(centerPanel);
this.centerPanel.add(repeatabilityLabel);
public final int getAILife() {
return aiLife;
}
/**
* <p>getQuests.</p>
* <p>getCardReward.</p>
*
* @return a {@link java.util.List} object.
* @return {@link java.lang.String}.
*/
public static List<QuestQuest> getQuests() {
List<QuestQuest> quests = new ArrayList<QuestQuest>();
List<Quest_Assignment> questList = readQuests();
for (Quest_Assignment assignment : questList) {
quests.add(new QuestQuest(assignment));
}
return quests;
public final String getCardReward() {
return cardReward;
}
/**
* <p>readQuests.</p>
* <p>getCreditsReward.</p>
*
* @return a {@link java.util.List} object.
* @return {@link java.lang.Integer}.
*/
private static List<Quest_Assignment> readQuests() {
forge.quest.data.QuestData questData = AllZone.getQuestData();
ReadQuest_Assignment read = new ReadQuest_Assignment(ForgeProps.getFile(NewConstants.QUEST.QUESTS), questData);
read.run();
List<Quest_Assignment> questsToDisplay = new ArrayList<Quest_Assignment>();
if (questData.getAvailableQuests() != null && questData.getAvailableQuests().size() > 0) {
List<Quest_Assignment> availableQuests = read.getQuestsByIds(questData.getAvailableQuests());
questsToDisplay = availableQuests;
} else {
List<Quest_Assignment> allAvailableQuests = read.getAvailableQuests();
List<Integer> availableInts = new ArrayList<Integer>();
int maxQuests = questData.getWin() / 10;
if (maxQuests > 5) {
maxQuests = 5;
}
if (allAvailableQuests.size() < maxQuests) {
maxQuests = allAvailableQuests.size();
}
Collections.shuffle(allAvailableQuests);
for (int i = 0; i < maxQuests; i++) {
Quest_Assignment qa = allAvailableQuests.get(i);
availableInts.add(qa.getId());
questsToDisplay.add(qa);
}
questData.setAvailableQuests(availableInts);
questData.saveData();
}//else
return questsToDisplay;
public final int getCreditsReward() {
return creditsReward;
}
/**
* <p>getQuestAssignment.</p>
* <p>getId.</p>
*
* @return a {@link forge.Quest_Assignment} object.
* @return {@link java.lang.Integer}.
*/
public Quest_Assignment getQuestAssignment() {
return assignment;
public final int getId() {
return id;
}
/**
* <p>getRepeatable.</p>
*
* @return {@link java.lang.Boolean}.
*/
public final boolean getRepeatable() {
return repeatable;
}
/**
* <p>getWinsReqd.</p>
*
* @return {@link java.lang.Integer}.
*/
public final int getWinsReqd() {
return winsReqd;
}
/**
* <p>getAIExtraCards.</p>
* Retrieves list of cards AI has in play at the beginning of this quest.
*
* @return
*/
public final CardList getAIExtraCards() {
return aiExtraCards;
}
/**
* <p>getHumanExtraCards.</p>
* Retrieves list of cards human has in play at the beginning of this quest.
*
* @return
*/
public final CardList getHumanExtraCards() {
return humanExtraCards;
}
/**
* <p>getCardRewardList.</p>
*
* @return
*/
public final List<CardPrinted> getCardRewardList() {
return cardRewardList;
}
}

View File

@@ -0,0 +1,35 @@
package forge.quest.gui.main;
//import javax.swing.JLabel;
/**
* <p>QuestQuestPanel.</p>
* VIEW - Creates a QuestSelectablePanel instance for a "quest" style event.
*/
@SuppressWarnings("serial")
public class QuestQuestPanel extends QuestSelectablePanel {
//private JLabel repeatabilityLabel;
/** <p>QuestQuestPanel.</p>
* Constructor, using quest data instance.
*
* @param {@link forge.quest.gui.main.QuestDuel}
*/
public QuestQuestPanel(QuestQuest q) {
super(q);
// Repeatability is currently meaningless.
// Can be added here later if necessary.
/*
* if (q.getRepeatable()) {
repeatabilityLabel = new JLabel("This quest is repeatable");
} else {
repeatabilityLabel = new JLabel("This quest is not repeatable");
}
super.rootPanel.add(repeatabilityLabel);
*/
}
}

View File

@@ -1,15 +1,19 @@
package forge.quest.gui.main;
import forge.gui.GuiUtils;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import javax.swing.*;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import java.awt.*;
import java.io.File;
/**
* <p>QuestSelectablePanel class.</p>
* VIEW - Creates a selectable panel, used for picking events.
*
* @author Forge
* @version $Id$
@@ -20,35 +24,38 @@ public class QuestSelectablePanel extends JPanel {
protected Color backgroundColor;
private boolean selected;
ImageIcon icon;
String name;
String description;
String difficulty;
JPanel centerPanel = new JPanel();
private QuestEvent event;
private String iconfilename;
public JPanel rootPanel = new JPanel();
/**
* <p>Constructor for QuestSelectablePanel.</p>
* VIEW - A JPanel for selecting quest events.
*
* @param name a {@link java.lang.String} object.
* @param difficulty a {@link java.lang.String} object.
* @param description a {@link java.lang.String} object.
* @param icon a {@link javax.swing.ImageIcon} object.
*/
public QuestSelectablePanel(String name, String difficulty, String description, ImageIcon icon) {
public QuestSelectablePanel(QuestEvent qe) {
this.event = qe;
this.iconfilename = qe.icon;
File base = ForgeProps.getFile(NewConstants.IMAGE_ICON);
File file = new File(base, iconfilename);
if(!file.exists()) {
file = new File(base,"Unknown.jpg");
this.iconfilename = "Unknown.jpg";
}
ImageIcon icon = new ImageIcon(file.toString());
this.backgroundColor = getBackground();
this.name = name;
this.difficulty = difficulty;
this.description = description;
this.icon = icon;
this.setLayout(new BorderLayout(5, 5));
JLabel iconLabel;
if (icon == null) {
if (icon.getIconHeight() == -1) {
iconLabel = new JLabel(GuiUtils.getEmptyIcon(40, 40));
} else {
iconLabel = new JLabel(GuiUtils.getResizedIcon(icon, 40, 40));
@@ -62,32 +69,32 @@ public class QuestSelectablePanel extends JPanel {
iconPanel.add(iconLabel, BorderLayout.NORTH);
this.add(iconPanel, BorderLayout.WEST);
centerPanel.setOpaque(false);
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
this.add(centerPanel, BorderLayout.CENTER);
rootPanel.setOpaque(false);
rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.Y_AXIS));
this.add(rootPanel, BorderLayout.CENTER);
JPanel centerTopPanel = new JPanel();
centerTopPanel.setOpaque(false);
centerTopPanel.setAlignmentX(LEFT_ALIGNMENT);
centerTopPanel.setLayout(new BoxLayout(centerTopPanel, BoxLayout.X_AXIS));
JLabel nameLabel = new JLabel(this.name);
JLabel nameLabel = new JLabel(qe.getTitle());
GuiUtils.setFontSize(nameLabel, 20);
nameLabel.setAlignmentY(BOTTOM_ALIGNMENT);
centerTopPanel.add(nameLabel);
GuiUtils.addExpandingHorizontalSpace(centerTopPanel);
JLabel difficultyLabel = new JLabel(this.difficulty);
JLabel difficultyLabel = new JLabel(qe.getDifficulty());
difficultyLabel.setAlignmentY(BOTTOM_ALIGNMENT);
centerTopPanel.add(difficultyLabel);
centerPanel.add(centerTopPanel);
rootPanel.add(centerTopPanel);
GuiUtils.addGap(centerPanel);
GuiUtils.addGap(rootPanel);
JLabel descriptionLabel = new JLabel(description);
JLabel descriptionLabel = new JLabel(qe.getDescription());
descriptionLabel.setAlignmentX(LEFT_ALIGNMENT);
centerPanel.add(descriptionLabel);
rootPanel.add(descriptionLabel);
this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 80));
this.setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(5, 5, 5, 5)));
@@ -117,9 +124,21 @@ public class QuestSelectablePanel extends JPanel {
this.selected = selected;
}
/** {@inheritDoc} */
@Override
public String getName() {
return name;
/**
* <p>getIconFilename.</p>
*
* @return String
*/
public String getIconFilename() {
return this.iconfilename;
}
/**
* <p>getEvent.</p>
*
* @return QuestEvent
*/
public QuestEvent getEvent() {
return this.event;
}
}

View File

@@ -1,41 +0,0 @@
package forge;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import org.testng.annotations.Test;
/**
* Created by IntelliJ IDEA.
* User: dhudson
*/
@Test(groups = {"UnitTest"}, timeOut = 1000)
public class ReadQuestAssignmentTest implements NewConstants {
/**
*
*
*/
@Test(groups = {"UnitTest", "fast"}, timeOut = 1000)
public void ReadQuestAssignmentTest1() {
try {
ReadQuest_Assignment read = new ReadQuest_Assignment(ForgeProps.getFile(QUEST.QUESTS), null);
javax.swing.SwingUtilities.invokeAndWait(read);
// read.run();
Quest_Assignment qa[] = new Quest_Assignment[read.allQuests.size()];
read.allQuests.toArray(qa);
for (int i = 0; i < qa.length; i++) {
System.out.println(qa[i].getId());
System.out.println(qa[i].getName());
System.out.println(qa[i].getDesc());
System.out.println(qa[i].getDifficulty());
System.out.println(qa[i].isRepeatable());
System.out.println(qa[i].getRequiredNumberWins());
}
} catch (Exception ex) {
ErrorViewer.showError(ex);
System.out.println("Error reading file " + ex);
}
}
}