This commit is contained in:
Giorgio Croci 2017-05-26 16:55:27 +02:00
commit fa72b365c0
3 changed files with 74 additions and 41 deletions

View File

@ -14,18 +14,18 @@ type Element struct { //struttura che contiene sia cibo sia amebe
} }
func (e Element) String() string { func (e Element) String() string {
return fmt.Sprintf("<E'Cibo=%t Salute=%d Eta=%d>", e.IsFood, e.Health, e.Age) return fmt.Sprintf("E'Cibo=%t Salute=%d Eta=%d", e.IsFood, e.Health, e.Age)
} }
func Costruttore(razza int, evoluzione int, costomov int, costosex int, premura int, salute int) *Element { func Costruttore(razza int, evoluzione int, costomov int, costosex int, premura int, salute int) *Element {
nuovo := new(Element) nuovo := new(Element)
nuovo.IsFood=false nuovo.IsFood = false
nuovo.Health=salute nuovo.Health = salute
nuovo.Age=0 nuovo.Age = 0
nuovo.Razza=razza nuovo.Razza = razza
nuovo.Evoluzione=evoluzione nuovo.Evoluzione = evoluzione
nuovo.CostoMov=costomov nuovo.CostoMov = costomov
nuovo.CostoSex=costosex nuovo.CostoSex = costosex
nuovo.Premura=premura nuovo.Premura = premura
return nuovo return nuovo
} }

View File

@ -16,5 +16,9 @@ func handlerRoot(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
} }
templ.Execute(w, new(interface{})) varmap := map[string]interface{}{
"matrice": Matrix,
"tempoAggiorna": Clock,
}
templ.Execute(w, varmap)
} }

View File

@ -1,56 +1,85 @@
<html> <html>
<head> <head>
<title>GoBug</title> <title>GoBug</title>
<!--meta http-equiv="refresh" content="{{ .tempoAggiorna }}"-->
<meta charset="UTF-8"> <meta charset="UTF-8">
<style type="text/css"> <style type="text/css">
h1,h2,h3,h4,p { h1,h2,h3,h4 {
color: white; color: white;
text-align: center; text-align: center;
font-size:2.4em; font-size:2.4em;
} }
body{ p {
color: white;
font-size:2em;
}
body {
background: #009999; background: #009999;
} }
table{ table {
border: 1px solid white; border: 1px solid white;
empty-cells: show; empty-cells: show;
background: white; background: white;
padding: 0px; padding: 0px;
width:100%; width:100%;
height: 100%;
}
div {
width:20%;
height: 89%; height: 89%;
background-color: #006666;
} }
td,tr{ td,tr {
background: white; background: white;
padding: 0px padding: 0px;
} }
td.cibo{ .cibo {
background: #FFFF33; background: #FFFF33;
padding: 0px padding: 0px;
} }
td.razza1{ .razza1 {
background: #00ff00; background: #00ff00;
padding: 0px padding: 0px;
}td.razza2{ }
background: #FF0000; .razza2 {
padding: 0px background: #FF0000;
padding: 0px;
} }
</style> </style>
</head> </head>
<body> <body>
<h1> Go bug</h1> <h1>Go bug</h1>
<div style="float:left; display:block; width:70%; height:89%; ">
<table> <table>
<tr> {{range $riga := .matrice}}
<td class="cibo"></th> <tr>
<td class="razza1"></td> {{range $cella := $riga}}
<td class="razza2"></td> <td {{ if not $cella }}
</tr> class="vuoto"
<tr> {{ else }}
<td></td> {{ if $cella.IsFood }}
<td></td> class="cibo"
<td></td> {{ else }}
</tr> class="razza1"
</table> {{ end }}
</body> {{ end }}>{{ $cella }}</td>
{{ end }}
</tr>
{{ end }}
</table>
</div>
<div style="float:left; display:block; width:1%; height:89%; "></div>
<div style="float:left; display:block; width:29%; height:89%; ">
<h1>legenda</h1>
<div style="float:left; display:block; width:30%; height:20%; background-color:#FFFF33;"></div>
<div style="float:right; display:block; width:65%; height:20%; "><p>Food</p></div>
<div style="float:right; display:block; width:100%; height:2%; "></div>
<div style="float:left; display:block; width:30%; height:20%; background-color:#00ff00;"></div>
<div style="float:right; display:block; width:65%; height:20%; "><p>Razza1</p></div>
<div style="float:right; display:block; width:100%; height:2%;"></div>
<div style="float:left; display:block; width:30%; height:20%; background-color:#F00;"></div>
<div style="float:right; display:block; width:65%; height:20%; "><p>Razza2</p></div>
</div>
</div>
</body>
</html> </html>