Skip to content

Commit

Permalink
Abstracted die values, refs Miniand/brdg.me-issues#52.
Browse files Browse the repository at this point in the history
  • Loading branch information
beefsack committed Jun 15, 2015
1 parent 6040862 commit 97f35a5
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 20 deletions.
2 changes: 1 addition & 1 deletion game/bang_dice/char_black_jack.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func (c CharBlackJack) Name() string {
func (c CharBlackJack) Description() string {
return fmt.Sprintf(
"You may re-roll %s. (Not if you roll three ore more!)",
DieStrings[DieDynamite],
RenderDie(DieDynamite),
)
}

Expand Down
4 changes: 2 additions & 2 deletions game/bang_dice/char_calamity_janet.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func (c CharCalamityJanet) Name() string {
func (c CharCalamityJanet) Description() string {
return fmt.Sprintf(
"You can use %s as %s and vice-versa.",
DieStrings[Die1],
DieStrings[Die2],
RenderDie(Die1),
RenderDie(Die2),
)
}

Expand Down
2 changes: 1 addition & 1 deletion game/bang_dice/char_jesse_jones.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func (c CharJesseJones) Name() string {
func (c CharJesseJones) Description() string {
return fmt.Sprintf(
"If you have four life points or less, you game two if you use %s for yourself.",
DieStrings[DieBeer],
RenderDie(DieBeer),
)
}

Expand Down
2 changes: 1 addition & 1 deletion game/bang_dice/char_kit_carlson.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func (c CharKitCarlson) Name() string {
func (c CharKitCarlson) Description() string {
return fmt.Sprintf(
"For each %s you may discard one arrow from any player.",
DieStrings[DieGatling],
RenderDie(DieGatling),
)
}

Expand Down
4 changes: 2 additions & 2 deletions game/bang_dice/char_rose_doolan.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func (c CharRoseDoolan) Name() string {
func (c CharRoseDoolan) Description() string {
return fmt.Sprintf(
"You may use %s or %s for players sitting one place further",
DieStrings[Die1],
DieStrings[Die2],
RenderDie(Die1),
RenderDie(Die2),
)
}

Expand Down
6 changes: 3 additions & 3 deletions game/bang_dice/char_slab_the_killer.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ func (c CharSlabTheKiller) Name() string {
func (c CharSlabTheKiller) Description() string {
return fmt.Sprintf(
"Once per turn, you can use a %s to double a %s or %s.",
DieStrings[DieBeer],
DieStrings[Die1],
DieStrings[Die2],
RenderDie(DieBeer),
RenderDie(Die1),
RenderDie(Die2),
)
}

Expand Down
4 changes: 2 additions & 2 deletions game/bang_dice/char_suzy_lafayette.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func (c CharSuzyLafayette) Name() string {
func (c CharSuzyLafayette) Description() string {
return fmt.Sprintf(
"If you didn't roll any %s or %s you gain two life points.",
DieStrings[Die1],
DieStrings[Die2],
RenderDie(Die1),
RenderDie(Die2),
)
}

Expand Down
4 changes: 2 additions & 2 deletions game/bang_dice/char_willy_the_kid.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func (c CharWillyTheKid) Name() string {
func (c CharWillyTheKid) Description() string {
return fmt.Sprintf(
"You only need %s%s to use the Gatling Gun.",
DieStrings[DieGatling],
DieStrings[DieGatling],
RenderDie(DieGatling),
RenderDie(DieGatling),
)
}

Expand Down
34 changes: 28 additions & 6 deletions game/bang_dice/dice.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package bang_dice

import (
"fmt"

"github.com/Miniand/brdg.me/render"
)

const (
DieArrow = iota
DieDynamite
Expand All @@ -9,11 +15,27 @@ const (
DieGatling
)

var DieColours = map[int]string{
DieArrow: render.Green,
DieDynamite: render.Red,
Die1: render.Black,
Die2: render.Black,
DieBeer: render.Yellow,
DieGatling: render.Blue,
}

var DieStrings = map[int]string{
DieArrow: `{{b}}[{{c "green"}}A{{_c}}]{{_b}}`,
DieDynamite: `{{b}}[{{c "red"}}D{{_c}}]{{_b}}`,
Die1: `{{b}}[1]{{_b}}`,
Die2: `{{b}}[2]{{_b}}`,
DieBeer: `{{b}}[{{c "yellow"}}B{{_c}}]{{_b}}`,
DieGatling: `{{b}}[{{c "blue"}}G{{_c}}]{{_b}}`,
DieArrow: "A",
DieDynamite: "D",
Die1: "1",
Die2: "2",
DieBeer: "B",
DieGatling: "G",
}

func RenderDie(die int) string {
return render.Bold(fmt.Sprintf(
"[%s]",
render.Colour(DieStrings[die], DieColours[die]),
))
}

0 comments on commit 97f35a5

Please sign in to comment.