瀏覽代碼

Fixed mark pos. Working sha1->rand.Seed.

Steve Thielemann 3 年之前
父節點
當前提交
a764d9caa0
共有 1 個文件被更改,包括 13 次插入8 次删除
  1. 13 8
      playcards.go

+ 13 - 8
playcards.go

@@ -4,6 +4,7 @@ import (
 	"crypto/sha1"
 	"encoding/binary"
 	"fmt"
+	"log"
 	"math/rand"
 	"red-green/door"
 	"strconv"
@@ -519,7 +520,7 @@ Next_Hand:
 	// Use play day to seed RNG
 	{
 		// Secret Squirrel method of seeding the RNG
-		sha1 := sha1.New()
+		Sha1 := sha1.New()
 		seed_seq := make([]byte, 0)
 
 		for _, seed := range pc.Seeds {
@@ -532,9 +533,13 @@ Next_Hand:
 		// We also need the hand # that we're playing.
 		seed_seq = append(seed_seq, byte(pc.Hand))
 
-		result := sha1.Sum(seed_seq)
+		Sha1.Write(seed_seq)
+		result := Sha1.Sum(nil)
 		var seed int64 = int64(binary.BigEndian.Uint64(result[0:8]))
 		pc.RNG.Seed(seed)
+		// I'm seeing changes in the seed_seq bytes, but the seed is the same number.
+		log.Printf("%#v\nSeed %d\nLen %d\nresult %#v\n", seed_seq, seed, len(seed_seq), result)
+
 		pc.Deck = ShuffleCards(pc.RNG, 1)
 		pc.State = MakeCardStates(1)
 	}
@@ -583,8 +588,8 @@ Next_Hand:
 				// Redisplay Mark / Selected Card
 				Pos := &CardPos[pc.Select_card]
 				c = &pc.DeckPanel.Mark[1]
-				c.X = Pos.X + pc.Off_X
-				c.Y = Pos.Y + pc.Off_Y
+				c.X = Pos.X + pc.Off_X + 2
+				c.Y = Pos.Y + pc.Off_Y + 2
 				pc.Door.Write(c.Output())
 			}
 		}
@@ -609,8 +614,8 @@ Next_Hand:
 						// Redisplay Mark / Selected Card
 						Pos := &CardPos[pc.Select_card]
 						c = &pc.DeckPanel.Mark[1]
-						c.X = Pos.X + pc.Off_X
-						c.Y = Pos.Y + pc.Off_Y
+						c.X = Pos.X + pc.Off_X + 2
+						c.Y = Pos.Y + pc.Off_Y + 2
 						pc.Door.Write(c.Output())
 					}
 				}
@@ -807,8 +812,8 @@ func (pc *PlayCards) Redraw(Dealing bool) {
 	{
 		Pos := &CardPos[pc.Select_card]
 		c = &pc.DeckPanel.Mark[1]
-		c.X = Pos.X + pc.Off_X
-		c.Y = Pos.Y + pc.Off_Y
+		c.X = Pos.X + pc.Off_X + 2
+		c.Y = Pos.Y + pc.Off_Y + 2
 		pc.Door.Write(c.Output())
 	}