-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard.adept
120 lines (105 loc) · 3.8 KB
/
Card.adept
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
import 'Offense.adept'
import 'Defense.adept'
import 'CardTraits.adept'
import 'CardBlueprint.adept'
import 'CardKind.adept'
import 'CardPosition.adept'
alias CardInstanceID = usize
alias CardNetworkID = usize
struct CardInstance (
instance_id CardInstanceID,
network_id CardNetworkID,
name, title, description String,
kind CardKind,
cost, hp, max_hp, attack int,
offense Offense,
defense Defense,
ct CardTextures,
traits CardTraits,
when_created double
) {
func __assign__(other CardInstance) {
this.instance_id = other.instance_id
this.network_id = other.network_id
this.name = other.name.clone()
this.title = other.title.clone()
this.description = other.description.clone()
this.kind = other.kind
this.cost = other.cost
this.hp = other.hp
this.max_hp = other.max_hp
this.attack = other.attack
this.offense = POD other.offense
this.defense = POD other.defense
this.ct = other.ct
this.traits = other.traits
this.when_created = other.when_created
}
func clone CardInstance {
instance POD CardInstance = *this
return instance
}
func getStandardCardTexture CaptTexture {
switch this.kind {
case CardKind::CREATURE, return textures.standard_creature_card
case CardKind::SPELL, return textures.standard_spell_card
case CardKind::STAT, return textures.standard_stat_card
case CardKind::TRAP, return textures.standard_trap_card
}
return textures.standard_card
}
func print {
print("% instance_id % network_id %" % this.name % this.instance_id % this.network_id)
print(" title: %" % this.title)
print(" description: %" % this.description)
print(" kind: %" % toString(this.kind))
print(" cost: %" % this.cost)
print(" hp: %/%" % this.hp % this.max_hp)
print(" attack: %" % this.attack)
print(" offense: %" % this.offense.toString())
print(" defense: %" % this.defense.toString())
print(" textures: %" % (this.ct.portrait != &textures.placeholder))
print(" traits: %" % this.traits.toString(false))
}
func assignNetworkID(network_id CardNetworkID) {
this.network_id = network_id
}
func heal(amount int) successful {
// NOTE: Returns whether any healing was done
// Cannot heal if marked as unhealable
if this.traits.unhealable, return false
// Cannot heal if already at maximum HP
if this.hp >= this.max_hp, return false
// Heal no more than up to maximum HP
this.hp = min(this.hp + amount, this.max_hp)
return true
}
func isDead bool = this.hp <= 0
func isSad bool {
if this.traits.on_fire && !this.traits.fire_resistant, return true
return false
}
func isDancing bool = this.traits.dancing > 0
}
func cardInstance(blueprint *CardBlueprint) CardInstance {
instance POD CardInstance
instance.instance_id = gamedata.next_instance_id++
instance.name = blueprint.name.clone()
instance.title = blueprint.title.clone()
instance.description = blueprint.description.clone()
instance.kind = blueprint.kind
instance.cost = blueprint.cost
instance.hp = blueprint.hp
instance.max_hp = blueprint.hp
instance.attack = blueprint.attack
instance.offense = POD blueprint.offense
instance.defense = POD blueprint.defense
instance.ct = blueprint.ct
instance.traits = blueprint.traits
instance.when_created = glfwGetTime()
return instance
}
func contains(this *<CardNetworkID> List, network_id CardNetworkID) bool {
each CardNetworkID in static *this, if it == network_id, return true
return false
}