Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
nlsui committed Apr 27, 2020
1 parent 1a8a60d commit b54ac0e
Show file tree
Hide file tree
Showing 20 changed files with 253 additions and 246 deletions.
4 changes: 2 additions & 2 deletions ability.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package cardobject
type activatedAbility struct {
AbilityCost int8
MultipleUse bool
Effects []effect
Effects []effect
}

type triggeredAbility struct {
Cause eventListener
Cause eventListener
Effects []effect
}

Expand Down
16 changes: 8 additions & 8 deletions card.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package cardobject

type cardAttributes struct {
Name string
Tags []string
Text string
Name string
Tags []string
Text string
CostType ressources
}

type action struct {
cardAttributes
CastingCost int8
Effects []effect
Effects []effect
}

type permanent struct {
Abilities []ability
Health int8
Health int8
}

type entity struct {
Expand All @@ -39,8 +39,8 @@ type headquarter struct {
}

type card struct {
Action *action `json:",omitempty"`
Entity *entity `json:",omitempty"`
Place *place `json:",omitempty"`
Action *action `json:",omitempty"`
Entity *entity `json:",omitempty"`
Place *place `json:",omitempty"`
Headquarter *headquarter `json:",omitempty"`
}
24 changes: 12 additions & 12 deletions cardString.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ func (c *card) toReadable() readableCard {
e := c.Entity
f := c.Place
h := c.Headquarter
if(a != nil) {
if a != nil {
return readableCard{*c, readable{a.toString()}}
}
if(e != nil) {
if e != nil {
return readableCard{*c, readable{e.toString()}}
}
if(f != nil) {
if f != nil {
return readableCard{*c, readable{f.toString()}}
}
if(h != nil) {
if h != nil {
return readableCard{*c, readable{h.toString()}}
}
return readableCard{}
Expand All @@ -34,9 +34,9 @@ func (c *card) toReadable() readableCard {
func (a *action) toString() string {
var effectsString []string
effects := a.Effects
if(effects != nil) {
if effects != nil {
for _, e := range effects {
effectsString = append(effectsString, e.toString())
effectsString = append(effectsString, e.toString())
}
}
return strings.Join(effectsString, "\n")
Expand All @@ -45,9 +45,9 @@ func (a *action) toString() string {
func (e *entity) toString() string {
var abilitiesString []string
abilities := e.Abilities
if(abilities != nil) {
if abilities != nil {
for _, a := range abilities {
abilitiesString = append(abilitiesString, a.toString())
abilitiesString = append(abilitiesString, a.toString())
}
}
return strings.Join(abilitiesString, "\n")
Expand All @@ -56,9 +56,9 @@ func (e *entity) toString() string {
func (f *place) toString() string {
var abilitiesString []string
abilities := f.Abilities
if(abilities != nil) {
if abilities != nil {
for _, a := range abilities {
abilitiesString = append(abilitiesString, a.toString())
abilitiesString = append(abilitiesString, a.toString())
}
}
return strings.Join(abilitiesString, "\n")
Expand All @@ -67,9 +67,9 @@ func (f *place) toString() string {
func (h *headquarter) toString() string {
var abilitiesString []string
abilities := h.Abilities
if(abilities != nil) {
if abilities != nil {
for _, a := range abilities {
abilitiesString = append(abilitiesString, a.toString())
abilitiesString = append(abilitiesString, a.toString())
}
}
return strings.Join(abilitiesString, "\n")
Expand Down
16 changes: 8 additions & 8 deletions condition.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package cardobject

type intCondition struct {
IntProperty string
IntProperty string
IntComparator string
IntValue int
IntValue int
}

type stringCondition struct {
StringProperty string
StringProperty string
StringComparator string
StringValue string
StringValue string
}

type tagCondition struct {
TagComparator string
TagValue string
TagValue string
}

type conditionAttributes struct {
IntCondition *intCondition `json:",omitempty"`
IntCondition *intCondition `json:",omitempty"`
StringCondition *stringCondition `json:",omitempty"`
TagCondition *tagCondition `json:",omitempty"`
TagCondition *tagCondition `json:",omitempty"`
}

type actionCondition struct {
Expand All @@ -42,5 +42,5 @@ type playerCondition struct {
type cardCondition struct {
ActionCondition *actionCondition `json:",omitempty"`
EntityCondition *entityCondition `json:",omitempty"`
PlaceCondition *placeCondition `json:",omitempty"`
PlaceCondition *placeCondition `json:",omitempty"`
}
7 changes: 2 additions & 5 deletions conditionString.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ func (cw *conditionAttributes) ToString() string {
var plainText string
ic := cw.IntCondition
sc := cw.StringCondition
if(ic != nil) {
if ic != nil {
return ic.ToString()
}
if(sc != nil) {
if sc != nil {
return sc.ToString()
}
return plainText
Expand All @@ -24,6 +24,3 @@ func (sc *stringCondition) ToString() string {
plainText := sc.StringProperty + " " + sc.StringComparator + " " + sc.StringValue
return plainText
}



26 changes: 13 additions & 13 deletions effect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@ package cardobject

type effect struct {
ProductionEffect *productionEffect `json:",omitempty"`
Draw *int `json:",omitempty"`
TokenEffect *tokenEffect `json:",omitempty"`
TargetEffect *targetEffect `json:",omitempty"`
Draw *int `json:",omitempty"`
TokenEffect *tokenEffect `json:",omitempty"`
TargetEffect *targetEffect `json:",omitempty"`
}

type productionEffect struct {
ProductionAmount int8
ProductionType ressources
ProductionType ressources
}

type targetEffect struct {
ActionTargetEffect *actionTargetEffect `json:",omitempty"`
EntityTargetEffect *entityTargetEffect `json:",omitempty"`
PlaceTargetEffect *placeTargetEffect `json:",omitempty"`
PlaceTargetEffect *placeTargetEffect `json:",omitempty"`
}

type actionTargetEffect struct {
ActionSelector actionSelector
ActionSelector actionSelector
ActionManipulations []actionManipulation `json:",omitempty"`
ZoneChange *zoneChange `json:",omitempty"`
ZoneChange *zoneChange `json:",omitempty"`
}

type entityTargetEffect struct {
EntitySelector entitySelector
EntitySelector entitySelector
EntityManipulations []entityManipulation `json:",omitempty"`
ZoneChange *zoneChange `json:",omitempty"`
ZoneChange *zoneChange `json:",omitempty"`
}

type placeTargetEffect struct {
PlaceSelector placeSelector
PlaceSelector placeSelector
PlaceManipulations []placeManipulation `json:",omitempty"`
ZoneChange *zoneChange `json:",omitempty"`
ZoneChange *zoneChange `json:",omitempty"`
}

type tokenEffect struct {
Amount *int8 `json:",omitempty"`
Token token
Token token
}

type zoneChange struct {
Zone string
Zone string
Player string
}
50 changes: 26 additions & 24 deletions effectString.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package cardobject

import "strings"
import "strconv"
import (
"strconv"
"strings"
)

func (e *effect) toString() string {
var sentences []string
Expand All @@ -10,20 +12,20 @@ func (e *effect) toString() string {
tokenEffect := e.TokenEffect
targetEffect := e.TargetEffect

if (targetEffect != nil) {
if targetEffect != nil {
sentences = append(sentences, targetEffect.toString())
}

if (tokenEffect != nil) {
if tokenEffect != nil {
sentences = append(sentences, tokenEffect.toString())
}

if (productionEffect != nil) {
if productionEffect != nil {
sentences = append(sentences, tokenEffect.toString())
}

if (draw != nil) {
sentences = append(sentences, "Draw " + strconv.Itoa(*draw) + " cards.")
if draw != nil {
sentences = append(sentences, "Draw "+strconv.Itoa(*draw)+" cards.")
}

return strings.Join(sentences, " ")
Expand All @@ -33,13 +35,13 @@ func (te *targetEffect) toString() string {
ate := te.ActionTargetEffect
ete := te.EntityTargetEffect
fte := te.PlaceTargetEffect
if(ate != nil) {
if ate != nil {
return ate.toString()
}
if(ete != nil) {
if ete != nil {
return ete.toString()
}
if(fte != nil) {
if fte != nil {
return fte.toString()
}
return ""
Expand All @@ -54,19 +56,19 @@ func (ate *actionTargetEffect) toString() string {
plural := false
manipulations := ate.ActionManipulations
zoneChange := ate.ZoneChange
if(ate.ActionSelector.CardMode == "ALL") {
if ate.ActionSelector.CardMode == "ALL" {
plural = true
}

sentences = append(sentences, ate.ActionSelector.toString())

if(manipulations != nil) {
if manipulations != nil {
for _, m := range manipulations {
sentences = append(sentences, m.toString(plural))
sentences = append(sentences, m.toString(plural))
}
}

if(zoneChange != nil) {
if zoneChange != nil {
sentences = append(sentences, zoneChangeString(zoneChange, plural))
}
return strings.Join(sentences, " ")
Expand All @@ -77,19 +79,19 @@ func (ete *entityTargetEffect) toString() string {
plural := false
manipulations := ete.EntityManipulations
zoneChange := ete.ZoneChange
if(ete.EntitySelector.CardMode == "ALL") {
if ete.EntitySelector.CardMode == "ALL" {
plural = true
}

sentences = append(sentences, ete.EntitySelector.toString())

if(manipulations != nil) {
if manipulations != nil {
for _, m := range manipulations {
sentences = append(sentences, m.toString(plural))
sentences = append(sentences, m.toString(plural))
}
}

if(zoneChange != nil) {
if zoneChange != nil {
sentences = append(sentences, zoneChangeString(zoneChange, plural))
}
return strings.Join(sentences, " ")
Expand All @@ -100,26 +102,26 @@ func (fte *placeTargetEffect) toString() string {
plural := false
manipulations := fte.PlaceManipulations
zoneChange := fte.ZoneChange
if(fte.PlaceSelector.CardMode == "ALL") {
if fte.PlaceSelector.CardMode == "ALL" {
plural = true
}

sentences = append(sentences, fte.PlaceSelector.toString())

if(manipulations != nil) {
if manipulations != nil {
for _, m := range manipulations {
sentences = append(sentences, m.toString(plural))
sentences = append(sentences, m.toString(plural))
}
}

if(zoneChange != nil) {
if zoneChange != nil {
sentences = append(sentences, zoneChangeString(zoneChange, plural))
}
return strings.Join(sentences, " ")
}

func zoneChangeString(zoneChange *zoneChange, plural bool) string {
if(plural) {
if plural {
return "Move them to " + zoneChange.Player + " " + zoneChange.Zone + "."
}
return "Move it to the " + zoneChange.Player + " " + zoneChange.Zone + "."
Expand All @@ -128,7 +130,7 @@ func zoneChangeString(zoneChange *zoneChange, plural bool) string {
func (toe *tokenEffect) toString() string {
var plainText string
plainText += "Create "
if (toe.Amount != nil) {
if toe.Amount != nil {
plainText += strconv.Itoa(int(*toe.Amount))
} else {
plainText += "a"
Expand Down
Loading

0 comments on commit b54ac0e

Please sign in to comment.