The basics of the game:
Basically, your objective is to either build your castle to 100 or completely destroy your opponents castle. You are dealt 8 cards at a time in which you can use to play with using your resources: Bricks, Weapons, and Crystals. Right now, it is completely multiplayer, two players can play as long as they are at the same computer, there is no AI like there is in the flash version. Also, once the AHK.net servers come back online, I plan to use those to make the game fully online capable (if anyone could suggest an alternative FTP server that allows to be used with AHK_FTP functions, I would get that done much sooner).
Features:
*It allows you to alter the stats of each card in the settings file.
*It allows you to alter the starting resources
*You can alter how many of each card are in the deck
*To make and add your own personalized card, just provide a graphic for the card and use the same naming convention as the others, maintaining the numerical order the cards go in. Next, just add the stats to the ini file.
You'll have to download the files separately as I do not have an appropriate FTP server to efficiently use to download all the files. The RAR is available to download at the link below.
Thank you and please rate! Inform me here of any bugs you have found or suggestions/updates to the code to make it better!
Link: Download

SetBatchLines, -1
Images=%A_ScriptDir%\Images
cTurn=1
sMod=Eca,Eal,All,Ebr,Ecr,Ewe,Atk,Est,Sto
Loop, %A_ScriptDir%\Images\Cards\*.png
bCard%A_Index%:=A_LoopFileLongPath
Loop, 30
{
IniRead, nCard%A_Index%, Settings.ini, CardNums, Card%A_Index%
;~ Msgbox, % nCard%A_Index%
CurCard:=nCard%A_Index%
Index:=A_Index
Loop, %CurCard%
CardList:=CardList ",Card" Index
}
StringTrimLeft, CardList, CardList, 1
CardList2 := CardList1 := oCardList1 := oCardList2 := CardList
IniRead, sBui, Settings.ini, StartStats, Bui
IniRead, sBri, Settings.ini, StartStats, Bri
IniRead, sSol, Settings.ini, StartStats, Sol
IniRead, sWea, Settings.ini, StartStats, Wea
IniRead, sWiz, Settings.ini, StartStats, Wiz
IniRead, sCry, Settings.ini, StartStats, Cry
IniRead, sCas, Settings.ini, StartStats, Cas
IniRead, sFen, Settings.ini, StartStats, Fen
Loop 30
{
IniRead, eCard%A_Index%, Settings.ini, CardEffects, Card%A_Index%
IniRead, cCard%A_Index%, Settings.ini, CardCost, Card%A_Index%
}
Loop 8
{
Index:=A_Index
Loop
{
Random, foo, 1, 30
bar=Card%foo%
If bar in %CardList1%
{
ListCut( ListPos("Card"foo, CardList1), CardList1)
p1Card%Index%=%foo%
Break
}
else
continue
}
}
Loop 8
{
Index:=A_Index
Loop
{
Random, foo, 1, 30
bar=Card%foo%
If bar in %CardList2%
{
ListCut( ListPos("Card"foo, CardList2), CardList2)
p2Card%Index%=%foo%
Break
}
else
continue
}
}
;~ Msgbox % pCard1 "`n" pCard2 "`n" pCard3 "`n" pCard4 "`n" pCard5 "`n" pCard6 "`n" pCard7 "`n" pCard8 "`n`n" CardList
Gui, Color, C3C3C3
;;;;;;;;;;;;;;;Player 1 GUI
Gui, Add, Picture, x12 y16 w90 h64, %Images%\ConColor.png
Gui, Add, GroupBox, x12 y10 w90 h70 , Construction
Gui, Add, Text, +BackgroundTrans x22 y30 w50 h20 , Builders:
Gui, Add, Text, +BackgroundTrans x22 y52 w50 h20 , Bricks:
Gui, Add, Edit, vsBui1 ReadOnly x72 y30 w20 h20 , %sBui%
Gui, Add, Edit, vsBri1 ReadOnly x72 y50 w20 h20 , %sBri%
Gui, Add, Picture, x12 y96 w90 h64, %Images%\ComColor.png
Gui, Add, GroupBox, x12 y90 w90 h70 , Combat
Gui, Add, Text, +BackgroundTrans x22 y110 w50 h20 , Soldiers:
Gui, Add, Text, +BackgroundTrans x22 y132 w50 h20 , Weapons:
Gui, Add, Edit, vsSol1 ReadOnly x72 y110 w20 h20 , %sSol%
Gui, Add, Edit, vsWea1 ReadOnly x72 y130 w20 h20 , %sWea%
Gui, Add, Picture, x12 y176 w90 h64, %Images%\MagColor.png
Gui, Add, GroupBox, x12 y170 w90 h70 , Magic
Gui, Add, Text, +BackgroundTrans x22 y190 w50 h20 , Wizards:
Gui, Add, Text, +BackgroundTrans x22 y212 w50 h20 , Crystals:
Gui, Add, Edit, vsWiz1 ReadOnly x72 y190 w20 h20 , %sWiz%
Gui, Add, Edit, vsCry1 ReadOnly x72 y210 w20 h20 , %sCry%
Gui, Add, Picture, x12 y256 w90 h64, %Images%\CasColor.png
Gui, Add, GroupBox, x12 y250 w90 h70 , Magic
Gui, Add, Text, +BackgroundTrans x22 y270 w50 h20 , Castle:
Gui, Add, Text, +BackgroundTrans x22 y292 w50 h20 , Fence:
Gui, Add, Edit, vsCas1 ReadOnly x72 y270 w20 h20 , %sCas%
Gui, Add, Edit, vsFen1 ReadOnly x72 y290 w20 h20 , %sFen%
Gui, Add, Text, x32 y322, Player 1
Gui, Add, Progress, vspCas1 x112 y15 w20 h305 Vertical, %sCas%
Gui, Add, Progress, vspFen1 x137 y15 w20 h305 Vertical, %sFen%
;;;;;;;;;;;;;;;Player2 GUI
Gui, Add, Picture, x509 y16 w90 h64, %Images%\ConColor.png
Gui, Add, GroupBox, x509 y10 w90 h70 , Construction
Gui, Add, Text, +BackgroundTrans x519 y30 w50 h20 , Builders:
Gui, Add, Text, +BackgroundTrans x519 y52 w50 h20 , Bricks:
Gui, Add, Edit, vsBui2 ReadOnly x559 y30 w20 h20 , %sBui%
Gui, Add, Edit, vsBri2 ReadOnly x559 y50 w20 h20 , %sBri%
Gui, Add, Picture, x509 y96 w90 h64, %Images%\ComColor.png
Gui, Add, GroupBox, x509 y90 w90 h70 , Combat
Gui, Add, Text, +BackgroundTrans x519 y110 w50 h20 , Soldiers:
Gui, Add, Text, +BackgroundTrans x519 y132 w50 h20 , Weapons:
Gui, Add, Edit, vsSol2 ReadOnly x559 y110 w20 h20 , %sSol%
Gui, Add, Edit, vsWea2 ReadOnly x559 y130 w20 h20 , %sWea%
Gui, Add, Picture, x509 y176 w90 h64, %Images%\MagColor.png
Gui, Add, GroupBox, x509 y170 w90 h70 , Magic
Gui, Add, Text, +BackgroundTrans x519 y190 w50 h20 , Wizards:
Gui, Add, Text, +BackgroundTrans x519 y212 w50 h20 , Crystals:
Gui, Add, Edit, vsWiz2 ReadOnly x559 y190 w20 h20 , %sWiz%
Gui, Add, Edit, vsCry2 ReadOnly x559 y210 w20 h20 , %sCry%
Gui, Add, Picture, x509 y256 w90 h64, %Images%\CasColor.png
Gui, Add, GroupBox, x509 y250 w90 h70 , Magic
Gui, Add, Text, +BackgroundTrans x519 y270 w50 h20 , Castle:
Gui, Add, Text, +BackgroundTrans x519 y292 w50 h20 , Fence:
Gui, Add, Edit, vsCas2 ReadOnly x559 y270 w20 h20 , %sCas%
Gui, Add, Edit, vsFen2 ReadOnly x559 y290 w20 h20 , %sFen%
Gui, Add, Text, x541 y322 w38, Player 2
Gui, Add, Progress, vspCas2 x479 y15 w20 h305 Vertical, %sCas%
Gui, Add, Progress, vspFen2 x454 y15 w20 h305 Vertical, %sFen%
;;;;;;;;;;;;;;;Cards
p1Card1:="bCard" p1Card1
p1Card2:="bCard" p1Card2
p1Card3:="bCard" p1Card3
p1Card4:="bCard" p1Card4
p1Card5:="bCard" p1Card5
p1Card6:="bCard" p1Card6
p1Card7:="bCard" p1Card7
p1Card8:="bCard" p1Card8
p2Card1:="bCard" p2Card1
p2Card2:="bCard" p2Card2
p2Card3:="bCard" p2Card3
p2Card4:="bCard" p2Card4
p2Card5:="bCard" p2Card5
p2Card6:="bCard" p2Card6
p2Card7:="bCard" p2Card7
p2Card8:="bCard" p2Card8
Gui, Add, Picture, vvCard1 ggCard1 x12 y350 w69 h104, % bCard %p1Card1%
Gui, Add, Picture, vvCard2 ggCard2 x86 y350 w69 h104, % bCard %p1Card2%
Gui, Add, Picture, vvCard3 ggCard3 x160 y350 w69 h104, % bCard %p1Card3%
Gui, Add, Picture, vvCard4 ggCard4 x234 y350 w69 h104, % bCard %p1Card4%
Gui, Add, Picture, vvCard5 ggCard5 x308 y350 w69 h104, % bCard %p1Card5%
Gui, Add, Picture, vvCard6 ggCard6 x382 y350 w69 h104, % bCard %p1Card6%
Gui, Add, Picture, vvCard7 ggCard7 x456 y350 w69 h104, % bCard %p1Card7%
Gui, Add, Picture, vvCard8 ggCard8 x530 y350 w69 h104, % bCard %p1Card8%
Gui, Add, Picture, vDiscarded1 x170 y80 w69 h104,
Gui, Add, Picture, vDiscarded2 x372 y80 w69 h104,
Gui, Add, Radio, vrPlay x234 y460 Checked, Play
Gui, Add, Radio, vrDiscard x308 y460, Discard
Gui, Font, s16 cFF7F27
Gui, Add, Text, vpTurn x240 y80 w131 Center, Player 1 Turn
Gui, Font, s36 cFF7F27
Gui, Add, Text, x165 y10 w281 Center, Castle Wars
Gui, Show, w611 h475, Castle Wars
MainGame:
GuiControl,, rPlay, 1
Gui, Submit, NoHide
If (cTurn = 1)
{
GuiControl,, pTurn, Player 1 Turn
GuiControl,, vCard1, % bCard %p1Card1%
GuiControl,, vCard2, % bCard %p1Card2%
GuiControl,, vCard3, % bCard %p1Card3%
GuiControl,, vCard4, % bCard %p1Card4%
GuiControl,, vCard5, % bCard %p1Card5%
GuiControl,, vCard6, % bCard %p1Card6%
GuiControl,, vCard7, % bCard %p1Card7%
GuiControl,, vCard8, % bCard %p1Card8%
}
else If (cTurn = 2)
{
GuiControl,, pTurn, Player 2 Turn
GuiControl,, vCard1, % bCard %p2Card1%
GuiControl,, vCard2, % bCard %p2Card2%
GuiControl,, vCard3, % bCard %p2Card3%
GuiControl,, vCard4, % bCard %p2Card4%
GuiControl,, vCard5, % bCard %p2Card5%
GuiControl,, vCard6, % bCard %p2Card6%
GuiControl,, vCard7, % bCard %p2Card7%
GuiControl,, vCard8, % bCard %p2Card8%
}
sBri%cTurn%:= sBri%cTurn% + sBui%cTurn%
sWea%cTurn%:= sWea%cTurn% + sSol%cTurn%
sCry%cTurn%:= sCry%cTurn% + sWiz%cTurn%
GuiControl,, sBri%cTurn%, % sBri%cTurn%
GuiControl,, sWea%cTurn%, % sWea%cTurn%
GuiControl,, sCry%cTurn%, % sCry%cTurn%
return
gCard1:
gCard2:
gCard3:
gCard4:
gCard5:
gCard6:
gCard7:
gCard8:
Gui, Submit, NoHide
StringTrimLeft, CardNum, A_ThisLabel, 5
StringReplace, WorCard, A_ThisLabel, g, p%cTurn%
WorCard:=%WorCard%
StringTrimLeft, cWorCard, WorCard, 5
If rPlay
{
StringSplit, Cost, cCard%cWorCard%, -
If (s%Cost1%%cTurn% >= Cost2)
{
s%Cost1%%cTurn%-=%Cost2%
GuiControl,, s%Cost1%%cTurn%, % s%Cost1%%cTurn%
}
else
Return
StringReplace, eWorCard, WorCard, b, e
StringSplit, CardEff, %eWorCard%, `,
Loop %CardEff0%
{
CurEff:=CardEff%A_index%
eLen:=StrLen(CurEff)
eLenr:=eLen - 4
StringTrimLeft, eMod, CurEff, 3
StringTrimRight, eMod, eMod, %eLenr%
StringSplit, Eff, CurEff, %eMod%
If Eff1 in %sMod%
{
If (cTurn = 1)
eTurn = 2
else If (cTurn = 2)
eTurn = 1
}
If Eff1 not in %sMod%
{
If (eMod = "+")
s%Eff1%%cTurn%:=s%Eff1%%cTurn% + Eff2
Else If (eMod = "-")
s%Eff1%%cTurn%:=s%Eff1%%cTurn% - Eff2
GuiControl,, s%Eff1%%cTurn%, % s%Eff1%%cTurn%
If (Eff1 = "Cas")
GuiControl,, spCas%cTurn%, % sCas%cTurn%
If (Eff1 = "Fen")
GuiControl,, spFen%cTurn%, % sFen%cTurn%
}
Else If (Eff1 = "Eca")
{
sCas%eTurn%:=sCas%eTurn% - Eff2
GuiControl,, sCas%eTurn%, % sCas%eTurn%
GuiControl,, spCas%eTurn%, % sCas%eTurn%
}
Else If (Eff1 = "Eal") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Eca,Eal,All,Ebr,Ecr,Ewe,Atk,Est,Sto
{
sBui%eTurn%:=sBui%eTurn% - Eff2
sBri%eTurn%:=sBri%eTurn% - Eff2
sSol%eTurn%:=sSol%eTurn% - Eff2
sWea%eTurn%:=sWea%eTurn% - Eff2
sWiz%eTurn%:=sWiz%eTurn% - Eff2
sCry%eTurn%:=sCry%eTurn% - Eff2
sCas%eTurn%:=sCas%eTurn% - Eff2
sFen%eTurn%:=sFen%eTurn% - Eff2
GuiControl,, sBui%eTurn%, % sBui%eTurn%
GuiControl,, sBri%eTurn%, % sBri%eTurn%
GuiControl,, sSol%eTurn%, % sSol%eTurn%
GuiControl,, sWea%eTurn%, % sWea%eTurn%
GuiControl,, sWiz%eTurn%, % sWiz%eTurn%
GuiControl,, sCry%eTurn%, % sCry%eTurn%
GuiControl,, sCas%eTurn%, % sCas%eTurn%
GuiControl,, spCas%eTurn%, % sCas%eTurn%
GuiControl,, sFen%eTurn%, % sFen%eTurn%
GuiControl,, spFen%eTurn%, % sFen%eTurn%
}
Else If (Eff1 = "All") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Eca,Eal,All,Ebr,Ecr,Ewe,Atk,Est,Sto
{
sBui%cTurn%:=sBui%cTurn% + Eff2
sBri%cTurn%:=sBri%cTurn% + Eff2
sSol%cTurn%:=sSol%cTurn% + Eff2
sWea%cTurn%:=sWea%cTurn% + Eff2
sWiz%cTurn%:=sWiz%cTurn% + Eff2
sCry%cTurn%:=sCry%cTurn% + Eff2
sCas%cTurn%:=sCas%cTurn% + Eff2
sFen%cTurn%:=sFen%cTurn% + Eff2
GuiControl,, sBui%cTurn%, % sBui%cTurn%
GuiControl,, sBri%cTurn%, % sBri%cTurn%
GuiControl,, sSol%cTurn%, % sSol%cTurn%
GuiControl,, sWea%cTurn%, % sWea%cTurn%
GuiControl,, sWiz%cTurn%, % sWiz%cTurn%
GuiControl,, sCry%cTurn%, % sCry%cTurn%
GuiControl,, sCas%cTurn%, % sCas%cTurn%
GuiControl,, spCas%cTurn%, % sCas%cTurn%
GuiControl,, sFen%cTurn%, % sFen%cTurn%
GuiControl,, spFen%cTurn%, % sFen%cTurn%
}
Else If (Eff1 = "Ebr")
{
sBri%eTurn%:=sBri%eTurn% - Eff2
GuiControl,, sBri%eTurn%, % sBri%eTurn%
}
Else If (Eff1 = "Ecr")
{
sCry%eTurn%:=sCry%eTurn% - Eff2
GuiControl,, sCry%eTurn%, % sCry%eTurn%
}
Else If (Eff1 = "Ewe")
{
sWea%eTurn%:=sWea%eTurn% - Eff2
GuiControl,, sWea%eTurn%, % sWea%eTurn%
}
Else If (Eff1 = "Sto")
{
sBri%cTurn%:=sBri%cTurn% + Eff2
sWea%cTurn%:=sWea%cTurn% + Eff2
sCry%cTurn%:=sCry%cTurn% + Eff2
GuiControl,, sBri%cTurn%, % sBri%cTurn%
GuiControl,, sWea%cTurn%, % sWea%cTurn%
GuiControl,, sCry%cTurn%, % sCry%cTurn%
}
Else If (Eff1 = "Est")
{
sBri%eTurn%:=sBri%eTurn% - Eff2
sWea%eTurn%:=sWea%eTurn% - Eff2
sCry%eTurn%:=sCry%eTurn% - Eff2
GuiControl,, sBri%eTurn%, % sBri%eTurn%
GuiControl,, sWea%eTurn%, % sWea%eTurn%
GuiControl,, sCry%eTurn%, % sCry%eTurn%
}
Else If (Eff1 = "Atk")
{
If (sFen%eTurn% >= Eff2)
{
sFen%eTurn%:=sFen%eTurn% - Eff2
GuiControl,, sFen%eTurn%, % sFen%eTurn%
GuiControl,, spFen%eTurn%, % sFen%eTurn%
}
Else If (sFen%eTurn% < 1)
{
sCas%eTurn%:=sCas%eTurn% - Eff2
GuiControl,, sCas%eTurn%, % sCas%eTurn%
GuiControl,, spCas%eTurn%, % sCas%eTurn%
}
Else If (sFen%eTurn% < Eff2)
{
ee:=Eff2 - sFen%eTurn%
sFen%eTurn%=0
sCas%eTurn%:=sCas%eTurn% - ee
GuiControl,, sCas%eTurn%, % sCas%eTurn%
GuiControl,, spCas%eTurn%, % sCas%eTurn%
GuiControl,, sFen%eTurn%, % sFen%eTurn%
GuiControl,, spFen%eTurn%, % sFen%eTurn%
}
}
}
}
GuiControl,, Discarded%cTurn%, % %WorCard%
Loop
{
Random, foo, 1, 30
bar=Card%foo%
If bar in % CardList%cTurn%
{
ListCut( ListPos(bar, CardList%cTurn%), CardList%cTurn%)
p%cTurn%Card%CardNum%=%foo%
p%cTurn%Card%CardNum%:="bCard" p%cTurn%Card%CardNum%
Break
}
}
If ( ListLen(CardList%cTurn%) < 5)
CardList%cTurn%:=oCardList%cTurn%
If (sCas%cTurn% >= 100)
{
Msgbox, Player %cTurn% wins!
ExitApp
}
If (sCas%eTurn% < 1)
{
Msgbox, Player %cTurn% wins!
ExitApp
}
If (cTurn = 1)
cTurn = 2
Else If (cTurn = 2)
cTurn = 1
Gosub MainGame
return
ESC::
GuiClose:
ExitApp
;;;;;;;The following functions were provided by Laszlo at http://www.autohotkey.com/community/viewtopic.php?t=3195
ListLen(list) ; how many items constitute the list
{
IfEqual list,, Return 0
StringReplace list, list, `,, `,, UseErrorLevel
Return ErrorLevel + 1
}
ListCut(pos, ByRef list) ; Remove & return item from list at pos, < 0 from end
{
_list_ = ,%list%, ; enclose in commas for search
Transform p1, ABS, pos
p2 := p1 + 1
IfGreater pos,-1, { ; pos > 0 counted from left, pos = 0: empty
StringGetPos ch1, _list_, `,, L%p1%
StringGetPos ch2, _list_, `,, L%p2%
}
Else IfLess pos,0, { ; pos < 0 counted from right
StringGetPos ch2, _list_, `,, R%p1%
StringGetPos ch1, _list_, `,, R%p2%
}
IfGreater ErrorLevel,0, Return ; nothing found
StringMid item, list, ch1+1, ch2-ch1-1
StringLeft leftlist, list, % ch1 - 1
StringTrimLeft rightlist, list, %ch2%
IfEqual rightlist,, SetEnv list, %leftlist%
Else IfEqual leftlist,, SetEnv list,%rightlist%
Else SetEnv list, %leftlist%,%rightlist%
Return %item%
}
ListPos(item,list) ; Return position of 1st copy of item, 0 if not found
{
_list_ = ,%list%, ; enclose in commas for search
StringGetPos ch, _list_, `,%item%`,
StringLeft list, _list_, % ch+1
StringReplace list, list, `,, `,, UseErrorLevel
Return %ErrorLevel%
}




