summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2020-01-07 19:42:33 -0500
committerBenjamin Chausse <benjamin@chausse.xyz>2020-01-07 19:42:33 -0500
commit045ed6354691a63c3f627dc2de71a1639efcda1c (patch)
tree436fe59a508ef5b0a8ffd4e1677faf65fc6a9391
parent67d49632b97d5ba439cb641cdf6b67ede2aed12f (diff)
testing continues
-rw-r--r--aesthetics.go69
-rw-r--r--main.go12
2 files changed, 70 insertions, 11 deletions
diff --git a/aesthetics.go b/aesthetics.go
index efc7cef..c2fe959 100644
--- a/aesthetics.go
+++ b/aesthetics.go
@@ -56,6 +56,75 @@ func (plyr player) TargetDisplay() string {
return text
}
+// printPrimary displays using ASCII art the primary battleship board
+func (plyr player) PrimarySlice() []string {
+ board := []string{
+ " ",
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ }
+ for i := 0; i < 10; i++ {
+ board = append(board, strconv.Itoa(i))
+ for j := 0; j < 10; j++ {
+ switch plyr.primary[i][j][2] {
+ case 0: // That coordinate was not hit
+ board = append(board, boatchars[1][plyr.primary[i][j][1]])
+ case 1: // That coordinates was hit
+ board = append(board, boatchars[0][plyr.primary[i][j][1]])
+ // default:
+ // return errors.New("Unknown State (hit/unhit) at a given coordinate")
+ }
+ }
+ }
+ // fmt.Println(text)
+ return board
+}
+
+func (plyr player) TargetSlice() []string {
+ board := []string{
+ " ",
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ }
+ for i := 0; i < 10; i++ {
+ board = append(board, strconv.Itoa(i))
+ for j := 0; j < 10; j++ {
+ switch plyr.target[i][j][0] {
+ case 0:
+ board = append(board, boatchars[1][0])
+ case 1:
+ if plyr.gains[plyr.prey.primary[i][j][0]] {
+ board = append(board, boatchars[0][plyr.prey.primary[i][j][1]])
+ } else {
+ switch plyr.prey.primary[i][j][0] {
+ case 0:
+ board = append(board, boatchars[0][0])
+ default:
+ board = append(board, mistery_hit)
+ }
+ }
+ }
+ }
+ }
+ return board
+}
+
// TODO: Function which returns what was hit as a commentary for the hitter
/* Boats Info:
diff --git a/main.go b/main.go
index cbfb1d9..c96c518 100644
--- a/main.go
+++ b/main.go
@@ -2,7 +2,6 @@ package main
import (
"fmt"
- "github.com/mbndr/figlet4go"
tv "github.com/rivo/tview"
)
@@ -22,16 +21,7 @@ func main() {
if settings.debug {
- ascii := figlet4go.NewAsciiRender()
-
- options := figlet4go.NewRenderOptions()
- options.FontName = "TwoPoint"
-
- // If 'larry3d' wouldn't be included you would have to load your .flf files like that:
- ascii.LoadFont("./ressources/")
-
- renderStr, _ := ascii.RenderOpts("Hello Fonts", options)
- fmt.Print(renderStr)
+ fmt.Println(player_one.PrimarySlice())
app := tv.NewApplication()
flex := tv.NewFlex().