-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07c5f05
commit b105517
Showing
16 changed files
with
175 additions
and
31 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
src/main/kotlin/org/hexworks/cavesofzircon/attributes/ZirconCounter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.hexworks.cavesofzircon.attributes | ||
|
||
import org.hexworks.cobalt.databinding.api.createPropertyFrom | ||
import org.hexworks.cobalt.databinding.api.expression.concat | ||
import org.hexworks.cobalt.databinding.api.property.Property | ||
import org.hexworks.zircon.api.Components | ||
import org.hexworks.zircon.api.component.Component | ||
|
||
data class ZirconCounter(private val zirconCountProperty: Property<Int> = createPropertyFrom(0)) : DisplayableAttribute { | ||
|
||
var zirconCount: Int by zirconCountProperty.asDelegate() | ||
|
||
override fun toComponent(width: Int): Component { | ||
val zirconProp = createPropertyFrom("Zircons: ") | ||
.concat(zirconCountProperty) { it.value.toString() } | ||
return Components.header() | ||
.withText(zirconProp.value) | ||
.withSize(width, 1) | ||
.build().apply { | ||
textProperty.updateFrom(zirconProp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/org/hexworks/cavesofzircon/attributes/types/ZirconHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.hexworks.cavesofzircon.attributes.types | ||
|
||
import org.hexworks.amethyst.api.entity.EntityType | ||
import org.hexworks.cavesofzircon.attributes.ZirconCounter | ||
import org.hexworks.cavesofzircon.extensions.GameEntity | ||
|
||
interface ZirconHolder : EntityType | ||
|
||
val GameEntity<ZirconHolder>.zirconCounter: ZirconCounter | ||
get() = findAttribute(ZirconCounter::class).get() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/org/hexworks/cavesofzircon/events/PlayerDied.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.hexworks.cavesofzircon.events | ||
|
||
import org.hexworks.cobalt.events.api.Event | ||
|
||
data class PlayerDied(val cause: String) : Event |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/org/hexworks/cavesofzircon/events/PlayerWonTheGame.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.hexworks.cavesofzircon.events | ||
|
||
import org.hexworks.cobalt.events.api.Event | ||
|
||
data class PlayerWonTheGame(val zircons: Int) : Event |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/org/hexworks/cavesofzircon/systems/ZirconGatherer.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.hexworks.cavesofzircon.systems | ||
|
||
import org.hexworks.amethyst.api.Command | ||
import org.hexworks.amethyst.api.Consumed | ||
import org.hexworks.amethyst.api.Pass | ||
import org.hexworks.amethyst.api.Response | ||
import org.hexworks.amethyst.api.base.BaseFacet | ||
import org.hexworks.amethyst.api.entity.EntityType | ||
import org.hexworks.cavesofzircon.attributes.ZirconCounter | ||
import org.hexworks.cavesofzircon.attributes.types.Zircon | ||
import org.hexworks.cavesofzircon.attributes.types.ZirconHolder | ||
import org.hexworks.cavesofzircon.attributes.types.zirconCounter | ||
import org.hexworks.cavesofzircon.commands.PickItemUp | ||
import org.hexworks.cavesofzircon.extensions.whenTypeIs | ||
import org.hexworks.cavesofzircon.functions.logGameEvent | ||
import org.hexworks.cavesofzircon.world.GameContext | ||
import org.hexworks.cobalt.datatypes.extensions.map | ||
|
||
object ZirconGatherer : BaseFacet<GameContext>(ZirconCounter::class) { | ||
|
||
override fun executeCommand(command: Command<out EntityType, GameContext>) = command.responseWhenCommandIs(PickItemUp::class) { | ||
val (context, source, position) = it | ||
var response: Response = Pass | ||
val world = context.world | ||
world.findTopItem(position).map { item -> | ||
source.whenTypeIs<ZirconHolder> { zirconHolder -> | ||
if (item.type == Zircon) { | ||
zirconHolder.zirconCounter.zirconCount++ | ||
world.removeEntity(item) | ||
logGameEvent("$zirconHolder picked up a Zircon!") | ||
response = Consumed | ||
} | ||
} | ||
} | ||
response | ||
} | ||
} |
20 changes: 13 additions & 7 deletions
20
src/main/kotlin/org/hexworks/cavesofzircon/view/LoseView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.