123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- package main
- import (
- "fmt"
- "log"
- "red-green/door"
- "strings"
- "time"
- )
- /*
- Yankee Trader has:
- CONFIG
- Max Number of sectors.
- Turns per day.
- Max number of holds.
- Number of Ports needed to reset the game.
- Number of days before a player is expired.
- Number of lottery plays per day.
- From yt-init:
- Sector map (what sectors go to what).
- Port information (sector, buying, selling, amounts...)
- MAINT -- The "old" maint is run as an event. I'd like to have it so
- it runs when a player plays. This might be tricky -- do I want it to
- run XX days of maint, if it hasn't been played in XX days?
- Ports need to be updated with their buying/selling amounts.
- Planets produce -- this would need to be updated.
- Xannor - attacks, and planet genesis.
- Wanderer - planet genesis (if missing).
- */
- func main() {
- var d door.Door = door.Door{}
- d.Init("yt2000")
- var message string
- var err error
- var key int
- _ = err
- d.Write(door.Clrscr + "\x1b[?1000h")
- d.Write(door.Reset + door.CRNL)
- // slow output here
- for _, line := range ANSIYtopen() {
- if door.Unicode {
- for _, c := range line {
- d.Write(string(c))
- // time.Sleep(time.Duration(5) * time.Millisecond)
- key = d.WaitKey(0, 5*1000)
- if key != -1 {
- d.Write(door.Reset + door.CRNL)
- goto abort
- }
- }
- } else {
- // Line gets mangled. Treat as bytes.
- var buff []byte = make([]byte, 1)
- for _, c := range []byte(line) {
- buff[0] = c
- d.Write(string(buff)) // string(c)
- // time.Sleep(time.Duration(5) * time.Millisecond)
- key = d.WaitKey(0, 5*1000)
- if key != -1 {
- d.Write(door.Reset + door.CRNL)
- goto abort
- }
- }
- }
- // d.Write(door.CRNL)
- }
- d.Write(door.Reset + door.CRNL)
- d.WaitKey(2, 0)
- YTSectors, err = BigBang(YTConfig{
- Sectors: 3000,
- Turns: 500,
- Holds: 10,
- PortReset: 1,
- DaysExpire: 30,
- Lottery: 12345,
- })
- if err != nil {
- log.Printf("BigBang() => %v", err)
- } else {
- for idx, sector := range YTSectors {
- log.Printf("IDX: %d = YTSector{Sector: %d, Planet: %v, Port: %v, Fighters: %d, FighterOwner: %d, Mines: %d, Sectors: %v, Players: %v}",
- idx, sector.Sector, sector.Planet, sector.Port, sector.Fighters, sector.FighterOwner, sector.Mines, sector.Sectors, sector.Players)
- }
- }
- abort:
- d.Write(door.Clrscr)
- var YtFont door.ColorFont = FontCyberWar()
- var yt []string
- var output []string
- var l int
- // Ok, that's wider then I was expecting! Yikes!
- if door.Width < 138 {
- yt = []string{"Yankee", "Trader", "2022"}
- } else {
- yt = []string{"Yankee Trader", "2022"}
- }
- for _, msg := range yt {
- output, l = YtFont.Output(msg)
- var center string
- if l < door.Width {
- center = strings.Repeat(" ", (door.Width-l)/2)
- } else {
- log.Println("[", msg, "]:", l, "Width:", door.Width)
- }
- for _, line := range output {
- d.Write(center + line + door.Reset + door.CRNL)
- }
- d.Write(door.CRNL)
- }
- d.Write(door.CRNL)
- d.Key()
- message = fmt.Sprintf("Returning to the %s BBS..."+door.CRNL, d.Config.BBSID)
- d.Write(message)
- d.WaitKey(1, 0)
- var left time.Duration = d.TimeLeft()
- message = fmt.Sprintf("You had %0.2f minutes remaining!"+door.CRNL, left.Minutes())
- d.Write(message)
- }
|