Skip to content

Commit

Permalink
Add HEALTH_ALL and use for enchantments
Browse files Browse the repository at this point in the history
The change and set effects can now take a Collection of resources to
change. This is utilized by HEALTH_ALL in CC. Fixes #384.
  • Loading branch information
jacwah committed Sep 7, 2015
1 parent 44e6cf7 commit a99b451
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
Expand Up @@ -178,20 +178,36 @@ class EffectDelegate {
}

def change(ECSResource resource) {
change([resource])
}

def change(Collection<ECSResource> resources) {
[by: {int amount ->
EntityConsumer action = {Entity source, Entity target ->
resource.retriever.resFor(target).change(amount)
resources.each {
it.retriever.resFor(target).change(amount)
}
}
targetedAction(action, "Change $resource by $amount on %who%\n")
// No [brackets] around resources
def resStr = String.join(", ", resources.stream().map({it.toString()}).collect(Collectors.toList()))

This comment has been minimized.

Copy link
@Zomis

Zomis Sep 7, 2015

Member

How about resources.stream().map({it.toString()}).collect(Collectors.joining(", ")) ?

targetedAction(action, "Change $resStr by $amount on %who%\n")
}]
}

def set(ECSResource resource) {
set([resource])
}

def set(Collection<ECSResource> resources) {
[to: {int amount ->
EntityConsumer action = {Entity source, Entity target ->
resource.retriever.resFor(target).set(amount)
resources.each {
it.retriever.resFor(target).set(amount)
}
}
targetedAction(action, "Set $resource to $amount on %who%\n")
// No [brackets] around resources
def resStr = String.join(", ", resources.stream().map({it.toString()}).collect(Collectors.toList()))
targetedAction(action, "Set $resStr to $amount on %who%\n")
}]
}

Expand Down
2 changes: 2 additions & 0 deletions extra-resources/mods/Cyborg-Chronicles/Game.groovy
Expand Up @@ -12,6 +12,8 @@ HEALTH = createResource("HEALTH")
MAX_HEALTH = createResource("MAX_HEALTH")
MANA_COST = createResource("MANA_COST")

HEALTH_ALL = [MAX_HEALTH, HEALTH]

// Resources that declare a specific special behavior to creature cards

ATTACK_AVAILABLE = createResource("ATTACK_AVAILABLE")
Expand Down
14 changes: 7 additions & 7 deletions extra-resources/mods/Cyborg-Chronicles/enchantments.cardset
Expand Up @@ -13,7 +13,7 @@ card('Body Armor') {
flavor "Steel-reinforced armor to absord damage from blows and shots."
enchantment()
afterPlay {
change HEALTH by 2 on targets
change HEALTH_ALL by 2 on targets
}
scrapCost 1
}
Expand All @@ -24,7 +24,7 @@ card('Adrenalin Injection') {
afterPlay {
set SICKNESS to 0 on targets // give "Rush"
change ATTACK by 1 on targets
change HEALTH by 1 on targets
change HEALTH_ALL by 1 on targets
}
scrapCost 1
}
Expand All @@ -34,7 +34,7 @@ card('Steroid Implants') {
enchantment()
afterPlay {
change ATTACK by 2 on targets
change HEALTH by 1 on targets
change HEALTH_ALL by 1 on targets
}
scrapCost 2
}
Expand All @@ -44,7 +44,7 @@ card('Reinforced Cranial Implants') {
enchantment()
afterPlay {
change ATTACK by 1 on targets
change HEALTH by 2 on targets
change HEALTH_ALL by 2 on targets
}
scrapCost 2
}
Expand All @@ -63,7 +63,7 @@ card('Exoskeleton') {
enchantment()
flavor "This very invasive operation reinforces bone tissue with titanium."
afterPlay {
change HEALTH by 3 on targets
change HEALTH_ALL by 3 on targets
}
scrapCost 2
}
Expand All @@ -73,7 +73,7 @@ card('Artificial Intelligence Implants') {
enchantment()
afterPlay {
change ATTACK by 2 on targets
change HEALTH by 3 on targets
change HEALTH_ALL by 3 on targets
}
scrapCost 3
}
Expand All @@ -83,7 +83,7 @@ card('Full-body Cybernetics Upgrade') {
enchantment()
afterPlay {
change ATTACK by 3 on targets
change HEALTH by 3 on targets
change HEALTH_ALL by 3 on targets
}
scrapCost 5
}

0 comments on commit a99b451

Please sign in to comment.