Skip to content
Permalink
Browse files

First commit

  • Loading branch information
Depado committed Aug 10, 2017
1 parent 62033f1 commit 3dc03a032841b461b4bc03fe9775d73e0942364b
Showing with 376 additions and 0 deletions.
  1. +33 −0 main.go
  2. +59 −0 models/character.go
  3. +39 −0 models/equipment.go
  4. +15 −0 models/inventory.go
  5. +15 −0 models/wealth.go
  6. +150 −0 nogaj.yml
  7. +65 −0 templates/index.html
33 main.go
@@ -0,0 +1,33 @@
package main

import (
"io/ioutil"
"net/http"

"github.com/gin-gonic/gin"

"github.com/Sirupsen/logrus"
yaml "gopkg.in/yaml.v2"

"github.com/Depado/rpsheet/models"
)

func main() {
var err error
var c []byte
var nogaj models.Character

if c, err = ioutil.ReadFile("nogaj.yml"); err != nil {
logrus.WithError(err).Fatal("Couldn't load file")
}
if err = yaml.Unmarshal(c, &nogaj); err != nil {
logrus.WithError(err).Fatal("Couldn't unmarshal")
}

r := gin.Default()
r.LoadHTMLGlob("templates/*")
r.GET("/", func(c *gin.Context) {
c.HTML(http.StatusOK, "index.html", nogaj)
})
r.Run(":8080")
}
@@ -0,0 +1,59 @@
package models

// Character represents a single player character
type Character struct {
Name string `yaml:"name"`
Age int `yaml:"age"`
FakeID string `yaml:"fake_id"`
Race string `yaml:"race"`
Height float64 `yaml:"height"`
Weight float64 `yaml:"weight"`
Origin string `yaml:"origin"`
PreferedHand string `yaml:"prefered_hand"`
XPs int `yaml:"xps"`
SpentXPs int `yaml:"spent_xps"`

HitPoints int `yaml:"hit_points"`
Fatigue int `yaml:"fatigue"`
ForcePoints int `yaml:"force_points"`
BaseMovement int `yaml:"base_movement"`

Wealth Wealth `yaml:"wealth"`

Formations []Formation `yaml:"formations"`
Talents []Talent `yaml:"talents"`
MainStats []Stat `yaml:"main_stats"`
ExtraStats []Stat `yaml:"extra_stats"`

Equipment Equipment `yaml:"equipment"`
Inventory []QuantifiedItem `yaml:"inventory"`
}

// 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"`
}

// Stat can be a main stat or an extra stat (in which case, rank and base
// are not taken into account)
type Stat struct {
Name string `yaml:"name"`
Base int `yaml:"base"`
Rank string `yaml:"rank"`
Modifier int `yaml:"modifier"`
}

// Formation represent a single formation (and what it does)
type Formation struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Modifier int `yaml:"modifier"`
}

// Talent represent a single talent and what it does
type Talent struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
}
@@ -0,0 +1,39 @@
package models

// Equipment groups all the stuff the player has equipped or can equip
type Equipment struct {
// Weapons
Weapons []Weapon `yaml:"weapons"`
RangedWeapons []RangedWeapon `yaml:"ranged_weapons"`

// Armors
Head []Armor `yaml:"head"`
ShoulderStrap []Armor `yaml:"shoulder_strap"`
Jacket []Armor `yaml:"jacket"`
Holster []Armor `yaml:"holster"`
Trouser []Armor `yaml:"trouser"`
Belt []Armor `yaml:"belt"`
Boots []Armor `yaml:"boots"`
Other []Armor `yaml:"other"`
}

// Armor is a simple armor
type Armor struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
}

// RangedWeapon describes a ranged weapon
type RangedWeapon struct {
Type string `yaml:"type"`
Scope int `yaml:"scope"` // In meters
Name string `yaml:"name"`
Damage DiceThrow `yaml:"damage"`
}

// Weapon describes a weapon (not ranged)
type Weapon struct {
Type string `yaml:"type"`
Name string `yaml:"name"`
Damage DiceThrow `yaml:"damage"`
}
@@ -0,0 +1,15 @@
package models

// QuantifiedItem adds a single quantity field to an item (for storage purpose)
type QuantifiedItem struct {
Item `yaml:",inline"`
Quantity int `yaml:"quantity"`
}

// Item represents a single item
type Item struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
Effect string `yaml:"effect"`
Unit string `yaml:"unit"`
}
@@ -0,0 +1,15 @@
package models

// Wealth is the money carried and in bank of the player
type Wealth struct {
Bank WealthStorage `yaml:"bank"`
Carried WealthStorage `yaml:"carried"`
}

// WealthStorage is a single place where wealth can be stored
type WealthStorage struct {
Platinium int `yaml:"platinum"`
Gold int `yaml:"gold"`
Silver int `yaml:"silver"`
Bronze int `yaml:"bronze"`
}
150 nogaj.yml
@@ -0,0 +1,150 @@
name: "Nogaj"
age: 323
race: Dwarf
height: 130
prefered_hand: Right
xps: 4590
spent_xps: 4170
hit_points: 20
fatigue: 3
force_points: 4
base_movement: 5
wealth:
bank:
platinum: 180
carried:
platinum: 32
gold: 35
silver: 5
formations:
- name: Guns
description: Increase base shooting skill with guns
modifier: 10
- name: Riffles
description: Increase base shooting skill with riffles
modifier: 10
- name: Drunk Man Technique
description: Close combat style
talents:
- name: Evangelism
description: Give some skills because of faith.
- name: Sniper
description: Remove some penalties for long-distance shooting
- name: Ammo Crafting
description: Allows to craft ammunitions
- name: Decadence
description: Improved alcohol resistance
- name: Heal
description: Jagon heals you or someone else
main_stats:
- name: Strength
base: 36
rank: C
- name: Agility
base: 54
rank: A
modifier: 10
- name: Stamina
base: 30
rank: B
- name: Intelligence
base: 32
rank: C
- name: Perception
base: 41
rank: A
modifier: 20
- name: Sociability
base: 66
rank: B
- name: Willpower
base: 31
rank: B
extra_stats:
- name: Baratin
modifier: 5
- name: Charisme
- name: Discretion
- name: Enquête
modifier: 5
- name: Evasion
modifier: 5
- name: Fouille
modifier: 5
- name: Intimidation
- name: Observation
modifier: 5
- name: Sang-froid
- name: Prosélitisme
modifier: 2
- name: Connaissances (Cultures anciennes)
- name: Démolition
- name: Subterfuge
equipment:
weapons:
- name: Épée +2
type: Sword
damage:
throws: 4
type: 6
- name: Krain & Nogaj
type: Hammers
damage:
throws: 10
type: 10
ranged_weapons:
- name: Lamagun
type: Gun
scope: 10
damage:
throws: 2
type: 10
- name: Dagues de jet
type: Daggers
damage:
throws: 2
type: 4
jacket:
- name: Cuir
description: Simple veste en cuir solide
inventory:
- name: Rations
quantity: 10
description: Permet de se sustenter
- name: Lampe
quantity: 1
description: Lampe à huile
- name: huile
quantity: 50
unit: cl
description: Huile inflammable
- name: Bandages
quantity: 10
unit: m
description: Bandages pour soigner les blessures
- name: Onguent
quantity: 1
unit: l
description: Onguent pour soigner les blessures
- name: Sac de couchage
quantity: 1
- name: Kit d'escalade
quantity: 1
- name: Briquet
quantity: 1
description: Briquet à amadou
- name: Acid Flask
quantity: 8
description: Flasque remplie d'acide
- name: Livre d'histoire naine
quantity: 2
description: Livre trouvé dans les mines
- name: Livres anciens
quantity: 2
description: Livres trouvés je sais plus où
- name: Dard d'abeille géante
quantity: 1
description: Un dard géant



@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Nogaj</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<style>
.demo-card > .mdl-card__title {
color: #fff;
background:
url('https://s-media-cache-ak0.pinimg.com/originals/79/27/71/792771f5b6a114a4ddeef9d8f3cce533.jpg') bottom right 15% no-repeat #46B6AC;
}
</style>
</head>
<body>
<div class="mdl-layout mdl-js-layout">
<main class="mdl-layout__content">
<div class="mdl-grid">
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--4-col">
<div class="mdl-card__supporting-text">
<ul class="mdl-list">
{{ range .Inventory }}
<li class="mdl-list__item mdl-list__item--three-line" style="height: 60px;">
<span class="mdl-list__item-primary-content">
<span>{{ .Quantity }}{{ if .Unit }}{{ .Unit }}{{ end }} {{ .Name }}</span>
<span class="mdl-list__item-text-body">
{{ .Description }}
</span>
</span>
</li>
{{ end }}
</ul>
</div>
</div>
<div class="mdl-card mdl-shadow--4dp mdl-cell mdl-cell--4-col">
<div class="mdl-card__supporting-text mdl-grid">
{{ range .MainStats }}
<div class="mdl-cell mdl-cell--6-col"><h4><span class="mdl-badge mdl-badge--no-background" data-badge="{{ .Rank }}">{{ .Name }}</span></h4></div>
<div class="mdl-cell mdl-cell--6-col"><h4>
{{ if .Modifier }}
<span class="mdl-badge mdl-badge--no-background" data-badge="+{{ .Modifier }}">{{ .Base }}</span>
{{ else }}
{{ .Base }}
{{ end }}
</h4></div>
{{ end }}
</div>
</div>
<div class="demo-card mdl-card mdl-shadow--4dp mdl-cell mdl-cell--4-col">
<div class="mdl-card__title mdl-card--expand">
<h2 class="mdl-card__title-text">{{ .Name }}</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Mauris sagittis pellentesque lacus eleifend lacinia...
</div>
</div>
</div>
</main>
</div>
</body>
</html>

0 comments on commit 3dc03a0

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