Skip to content
Permalink
Browse files

Spells and improved weapons

  • Loading branch information...
Depado committed Sep 12, 2017
1 parent 55030d6 commit 771c170b75e419c06add3b68de45452aef995d21
Showing with 113 additions and 38 deletions.
  1. +7 −3 models/character.go
  2. +7 −4 models/equipment.go
  3. +17 −3 models/talents.go
  4. +1 −0 templates/index.tmpl
  5. +32 −0 templates/spells.tmpl
  6. +49 −28 templates/weapons.tmpl
@@ -33,6 +33,7 @@ type Character struct {
Talents []Talent `yaml:"talents"`
Stats []Stat `yaml:"stats"`
Skills []Stat `yaml:"skills"`
Spells []Spell `yaml:"spells"`

Equipment Equipment `yaml:"equipment"`
Inventory []QuantifiedItem `yaml:"inventory"`
@@ -68,14 +69,17 @@ func (c *Character) Enrich() {
for i := range c.Equipment.RangedWeapons {
c.Equipment.RangedWeapons[i].MatchIcon()
}
for i := range c.Spells {
c.Spells[i].Enrich()
}
}

// DiceThrow defines the way dice throws are represented
// For exemple 10D10 → Throws: 10, Type: 10
type DiceThrow struct {
Throws int `yaml:"throws"`
Type int `yaml:"type"`
PerRank int `yaml:"per_rank"`
Throws int `yaml:"throws"`
Type int `yaml:"type"`
PerRank bool `yaml:"per_rank"`
}

// Stat can be a main stat or an extra stat (in which case, rank and base
@@ -24,10 +24,13 @@ type Equipment struct {

// Weapon describes a weapon (not ranged)
type Weapon struct {
Type string `yaml:"type"`
Icon string `yaml:"icon"`
Name string `yaml:"name"`
Damage DiceThrow `yaml:"damage"`
Type string `yaml:"type"`
Icon string `yaml:"icon"`
Name string `yaml:"name"`
Notes []string `yaml:"notes"`
Modifiers []string `yaml:"modifiers"`
Damage DiceThrow `yaml:"damage"`
Description string `yaml:"description"`
}

// MatchIcon will assign a default icon if none is set
@@ -1,5 +1,7 @@
package models

import "fmt"

// Formation represent a single formation (and what it does)
type Formation struct {
Name string `yaml:"name"`
@@ -16,7 +18,19 @@ type Talent struct {

// Spell is a talent with an associated test and a score
type Spell struct {
Talent
Score DiceThrow `yaml:"throw"`
Test string `yaml:"test"`
Talent `yaml:",inline"`
Score DiceThrow `yaml:"score"`
Test string `yaml:"test"`
Scope int `yaml:"scope"`
Modifier int `yaml:"modifier"`
FmtModifier string
}

// Enrich adds some formatted fields
func (s *Spell) Enrich() {
if s.Modifier > 0 {
s.FmtModifier = fmt.Sprintf("+ %d", s.Modifier)
} else if s.Modifier < 0 {
s.FmtModifier = fmt.Sprintf("- %d", s.Modifier)
}
}
@@ -40,6 +40,7 @@
<div class="mdl-grid">
{{ template "weapons_card" . }}
{{ template "skills_card" . }}
{{ template "spells_card" . }}
</div>
</main>
</div>
@@ -0,0 +1,32 @@
{{ define "spells_card" }}
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--6-col">
<div class="mdl-card__title mdl-color--light-blue-400 mdl-color-text--grey-100">
<h2 class="mdl-card__title-text"><img src="/assets/img/spellbook.svg" height="30px">&nbsp;&nbsp; Spells</h2>
</div>
<div class="mdl-card__supporting-text mdl-grid">
{{ range .Spells }}
<div class="mdl-cell mdl-cell--12-col">
<h5>{{ .Name }}</h4>
<hr>
<p>
<img src="/assets/img/dice.svg" height="25px"> {{ .Score.Throws }}D{{ .Score.Type }}{{ if .Score.PerRank }} per rank{{ end }}{{ if .FmtModifier}} {{ .FmtModifier }}{{ end }}
</p>
{{ if .Test }}
<p>
<img src="/assets/img/test.svg" height="25px"> {{ .Test }}
</p>
{{ end }}
<p>
<img src="/assets/img/crosshair.svg" height="25px"> {{ if .Scope }}{{ .Scope }}m{{ else }}Physical{{ end }}
</p>
{{ if .Description }}
<p>
<img src="/assets/img/book.svg" height="25px"> {{ .Description }}
</p>
{{ end }}
<hr />
</div>
{{ end }}
</div>
</div>
{{ end }}
@@ -4,38 +4,59 @@
<h2 class="mdl-card__title-text"><img src="/assets/img/weapons.svg" height="30px">&nbsp;&nbsp; Weapons</h2>
</div>
<div class="mdl-card__supporting-text mdl-grid">
<div class="mdl-cell mdl-cell--6-col">
<h4 style="text-align: center;">Physical</h4>
<ul class="mdl-list">
<div class="mdl-cell mdl-cell--6-col mdl-grid">
{{ range .Equipment.Weapons }}
<li class="mdl-list__item mdl-list__item--three-line">
<span class="mdl-list__item-primary-content">
<img class="mdl-list__item-avatar" src="/assets/items/{{ .Icon }}" style="background-color:#fff; margin-bottom: 20px;">
<span>{{ .Name }}</span>
<span class="mdl-list__item-text-body">
{{ .Damage.Throws }}D{{ .Damage.Type }}
</span>
</span>
</li>
<div class="mdl-cell mdl-cell--12-col">
<h5><img src="/assets/items/{{ .Icon }}" style="height: 30px;"> {{ .Name }}</h5>
<hr />
<p>
<span><img src="/assets/img/dice.svg" height="25px"> {{ .Damage.Throws }}D{{ .Damage.Type }}</span>
</p>
{{ range .Notes }}
<p>
<img src="/assets/img/book.svg" height="25px"> {{ . }}
</p>
{{ end }}
{{ range .Modifiers }}
<p>
<img src="/assets/img/main_stats_dark.svg" height="25px"> {{ . }}
</p>
{{ end }}
{{ if .Description }}
<p style="text-align: justify;"><i>{{ .Description }}</i></p>
{{ end }}
<hr />
</div>
{{ end }}
</ul>
</div>
<div class="mdl-cell mdl-cell--6-col">
<h4 style="text-align: center;">Ranged</h4>
<ul class="mdl-list">
</div>
<div class="mdl-cell mdl-cell--6-col mdl-grid">
{{ range .Equipment.RangedWeapons }}
<li class="mdl-list__item mdl-list__item--three-line">
<span class="mdl-list__item-primary-content">
<img class="mdl-list__item-avatar" src="/assets/items/{{ .Icon }}" style="background-color:#fff; margin-bottom: 20px;">
<span>{{ .Name }}</span>
<span class="mdl-list__item-text-body">
{{ .Damage.Throws }}D{{ .Damage.Type }}{{ if .Scope }} - {{ .Scope }}m{{ end }}
</span>
</span>
</li>
<div class="mdl-cell mdl-cell--12-col">
<h5><img src="/assets/items/{{ .Icon }}" style="height: 30px;"> {{ .Name }}</h5>
<hr />
<p>
<span><img src="/assets/img/dice.svg" height="25px"> {{ .Damage.Throws }}D{{ .Damage.Type }}</span>
{{ if .Scope }}
<span style="float: right;"><img src="/assets/img/crosshair.svg" height="25px"> {{ .Scope }}m</span>
{{ end }}
</p>
{{ range .Notes }}
<p>
<img src="/assets/img/book.svg" height="25px"> {{ . }}
</p>
{{ end }}
{{ range .Modifiers }}
<p>
<img src="/assets/img/main_stats_dark.svg" height="25px"> {{ . }}
</p>
{{ end }}
{{ if .Description }}
<p style="text-align: justify;"><i>{{ .Description }}</i></p>
{{ end }}
<hr />
</div>
{{ end }}
</ul>
</div>
</div>
</div>
</div>
{{ end }}

0 comments on commit 771c170

Please sign in to comment.
You can’t perform that action at this time.