-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lesson_2.lua
173 lines (168 loc) · 7.78 KB
/
lesson_2.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
require 'herorealms'
require 'decks'
require 'stdlib'
require 'timeoutai'
require 'hardai_2'
require 'aggressiveai'
--=======================================================================================================
--This lua file builds on the one from lesson #1, Player 1 and 2 were swapped from before so the 2nd player
--would be an AI bot witha random charcter/build and player 1 would have a custom loadout.
--
--The new thing here is the creation and use of a custom Action card in player 1's deck.
--I removed most of the comments form lesson #1 so i could add new ones to call attention to
--all the things that you have to do to make a new action card.
--=======================================================================================================
function setupGame(g)
registerCards(g, {
--Anytime you make a new card/skill/ability/armor you need to put them here to be registered before you can use it.
teach_them_a_lesson_carddef()
})
standardSetup(g, {
description = "Lesson #2: Custom Action Cards<br>Created by WardenSlayer.",
playerOrder = { plid1, plid2 },
ai = ai.CreateKillSwitchAi(createAggressiveAI(), createHardAi2()),
timeoutAi = createTimeoutAi(),
opponents = { { plid1, plid2 } },
players = {
{
id = plid1,
startDraw = 3,
name = "Lua Lesson Warrior",
avatar="assassin",
health = 50,
cards = {
deck = {
--Here the custom action card is added to player 1's deck
{ qty=4, card=teach_them_a_lesson_carddef()},
{ qty=8, card=gold_carddef() },
},
skills = {
{qty = 1, card = thief_lift_carddef() },
{qty = 1, card = fighter_devastating_blow_carddef()},
{qty = 1, card = ranger_hunters_cloak_carddef()},
},
buffs = {
drawCardsCountAtTurnEndDef(5),
discardCardsAtTurnStartDef(),
fatigueCount(40, 1, "FatigueP1")
}
}
},
{
--Player 2 is an AI controlled player. They will have a random class/build each time
--The AI is always the same level as the player's character.
id = plid2,
isAi = true,
startDraw = 5,
init = {
fromEnv = plid2
},
cards = {
buffs = {
drawCardsCountAtTurnEndDef(5),
discardCardsAtTurnStartDef(),
fatigueCount(40, 1, "FatigueP2"),
}
}
},
}
})
end
--=======================================================================================================
--When making a custom card of any type, it starts with a declaration function like this.
--There are 2 main steps to making a custom card.
-- 1) Designing the layout of the card (to include the actual abilities the card has)
-- 2) Coding the functionality of card
function teach_them_a_lesson_carddef()
--This first section creates a card layout for use later on
local cardLayout = createLayout({
--This is the dispaly text ont he card title
name = "Teach Them a Lesson",
--This sets the art that displays on card (you can find these in the art section of the Lua Doc)
art = "art/T_Seek_Revenge",
--This sets the card frame/border art that displays on card (you can find these in the frames section of the Lua Doc)
frame = "frames/Ranger_CardFrame",
--This is the card type display text that appears at the top center of the card
cardTypeLabel = "Action",
--This part generates the card ability text that tells you what the card does
--This xmlText was generated by using the card designer
xmlText = [[
<vlayout>
<box flexibleheight="1">
<tmpro text="<cspace=1.0em>{combat_2}</cspace>" fontsize="48"/>
<tmpro text="<cspace=-1em>{gold_2}</cspace>" fontsize="48"/>
</box>
<divider/>
<hlayout flexibleheight="1">
<box flexiblewidth="1">
<tmpro text="{scrap}" fontsize="36"/>
</box>
<box flexiblewidth="7">
<tmpro text="Opponent discards 2." fontsize="22" />
</box>
</hlayout>
</vlayout>
]]
})
--This next section populated the object data for the card l
--and is how you controwhat the card can do
return createActionDef({
--The cards ID which can be used t identify it in other places
id = "teach_them_a_lesson_card",
--The card's name but not the one you see on the card image.
name = "Teach Them a Lesson",
--If you were to buy the card how much would it cost
acquireCost = 0,
--This is the card type display text that appears at the top center of the card
cardTypeLabel = "Action",
--Here you define what types the card has so it can interact with other cards
--that do different things base don type
--ActionType for actions, noStealType is for starter cards or cards you dont want a thief to be able to steal
--other exmaples (like meleeWeaponType or bowType) can befound in the card subtypes section of the Lua document)
types = { actionType, noStealType },
--Here we finally use the layout created above to set the visual display for the card
layout = cardLayout,
--Where the card is played, for actions that is castPloc which is different then where champions are played
playLocation = castPloc,
--This last section creates object data to make the card work.
--A card can have any number of abilities but this one has two.
abilities = {
--This ability triggers any time the card is played and gives 2 combat and 2 gold.
createAbility({
id = "teachMain",
--Auto trigger means it triggers as soon as it played (other trigger options can be found in the Lua Doc)
trigger = autoTrigger,
effect = gainCombatEffect(2).seq(gainGoldEffect(2)),
}),
--This ability only tiggers when the user tells it to, it sacrifices the card
--for an ability (like a fire gem)
createAbility({
id = "teachSac",
--requires player interaction to trigger
trigger = uiTrigger,
--the prompt is what you see when you click on a card to make it bigger to read it
promptType = showPrompt,
--The prompt layout does not automatically use the same layout as the card. Here they are forced to be the same thing.
layout = cardLayout,
--Cost is used to make the player pay something to activate the effect. Here the cost is the card itself is sacrificed.
cost = sacrificeSelfCost,
effect = oppDiscardEffect(2)
}),
}
})
end
--=======================================================================================================
function endGame(g)
end
--=======================================================================================================
function setupMeta(meta)
meta.name = "lesson_2"
meta.minLevel = 0
meta.maxLevel = 0
meta.introbackground = ""
meta.introheader = ""
meta.introdescription = ""
meta.path = "C:/Users/xTheC/Desktop/Git Repositories/Hero-Realms-Lua-Lessons/Lua Lesson #2/lesson_2.lua"
meta.features = {
}
end