site history

This commit is contained in:
Robert Janetzko 2022-04-29 13:33:21 +00:00
parent 09b2527115
commit 0282977343
6 changed files with 13 additions and 12 deletions

View File

@ -23,7 +23,7 @@
"Entity": [
{
"Name": "Sites",
"Type": "map[int]*Site"
"Type": "[]int"
}
],
"Site": [

View File

@ -9,6 +9,7 @@ require (
github.com/iancoleman/strcase v0.2.0
github.com/pkg/profile v1.6.0
github.com/shirou/gopsutil v3.21.11+incompatible
golang.org/x/exp v0.0.0-20220428152302-39d4317da171
)
require (

View File

@ -27,10 +27,11 @@ github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKl
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/exp v0.0.0-20220428152302-39d4317da171 h1:TfdoLivD44QwvssI9Sv1xwa5DcL5XQr4au4sZ2F2NV4=
golang.org/x/exp v0.0.0-20220428152302-39d4317da171/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 h1:xHms4gcpe1YE7A3yIllJXP16CMAGuqwO2lX1mTyyRRc=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@ -1987,13 +1987,12 @@ type Entity struct {
Type_ EntityType `json:"type" legend:"plus"` // type
Weapon []EntityWeapon `json:"weapon" legend:"plus"` // weapon
WorshipId []int `json:"worshipId" legend:"plus"` // worship_id
Sites map[int]*Site `json:"sites" legend:"add"` // Sites
Sites []int `json:"sites" legend:"add"` // Sites
}
func NewEntity() *Entity {
return &Entity{
Id_: -1,
Sites: make(map[int]*Site),
}
}
func (x *Entity) Id() int { return x.Id_ }

View File

@ -1,8 +1,9 @@
package model
import (
"fmt"
"strings"
"golang.org/x/exp/slices"
)
func (w *DfWorld) process() {
@ -57,10 +58,9 @@ func (w *DfWorld) processEvents() {
}
func (w *DfWorld) addEntitySite(entityId, siteId int) {
fmt.Println("add site", entityId, siteId)
if e, ok := w.Entities[entityId]; ok {
if s, ok := w.Sites[siteId]; ok {
e.Sites[s.Id_] = s
if !slices.Contains(e.Sites, siteId) {
e.Sites = append(e.Sites, siteId)
}
}
}

View File

@ -8,10 +8,10 @@
<h5>Sites</h5>
<table>
{{- range $i, $s := .Sites }}
{{- range .Sites }}
<tr>
<td> {{ site $s.Id }}</td>
<td> {{ template "events.html" events (history $s.Id) }}</td>
<td> {{ site . }}</td>
<td> {{ template "events.html" events (history .) }}</td>
</tr>
{{- end }}
</table>