瀏覽代碼

Changed rune to string. Whew.

Steve Thielemann 3 年之前
父節點
當前提交
4d44a1e245
共有 2 個文件被更改,包括 48 次插入41 次删除
  1. 39 40
      deck.go
  2. 9 1
      playcards.go

+ 39 - 40
deck.go

@@ -1,7 +1,6 @@
 package main
 
 import (
-	"bytes"
 	"math/rand"
 	"red-green/door"
 	"strings"
@@ -55,13 +54,13 @@ func CardOf(c int) door.Panel {
 	s := SuitSymbol(suit)
 
 	p.Lines = append(p.Lines,
-		door.Line{Text: string(r) + string(s) + "   ",
+		door.Line{Text: r + s + "   ",
 			DefaultColor: color})
 	p.Lines = append(p.Lines,
-		door.Line{Text: "  " + string(s) + "  ",
+		door.Line{Text: "  " + s + "  ",
 			DefaultColor: color})
 	p.Lines = append(p.Lines,
-		door.Line{Text: "   " + string(s) + string(r),
+		door.Line{Text: "   " + s + r,
 			DefaultColor: color})
 	return p
 }
@@ -72,16 +71,8 @@ func BackOf(level int) door.Panel {
 		Y:     0,
 		Width: 5,
 	}
-	var back string
 
-	if door.Unicode {
-		back = strings.Repeat(string(BackSymbol(level)), 5)
-	} else {
-		// bytes get destroyed as string.
-		br := make([]byte, 1)
-		br[0] = byte(BackSymbol(level))
-		back = string(bytes.Repeat(br, 5))
-	}
+	var back string = strings.Repeat(BackSymbol(level), 5)
 
 	for x := 0; x < 3; x++ {
 		p.Lines = append(p.Lines,
@@ -118,79 +109,79 @@ func MarkOf(c int) door.Panel {
 	return p
 }
 
-func RankSymbol(c int) rune {
+func RankSymbol(c int) string {
 	const symbols = "A23456789TJQK"
-	return rune(symbols[c])
+	return symbols[c : c+1]
 }
 
-func SuitSymbol(c int) rune {
+func SuitSymbol(c int) string {
 	if door.Unicode {
 		switch c {
 		case 0:
-			return '\u2665'
+			return "\u2665"
 		case 1:
-			return '\u2666'
+			return "\u2666"
 		case 2:
-			return '\u2663'
+			return "\u2663"
 		case 3:
-			return '\u2660'
+			return "\u2660"
 		}
 	} else {
 		if door.Full_CP437 {
 			switch c {
 			case 0:
-				return '\x03'
+				return "\x03"
 			case 1:
-				return '\x04'
+				return "\x04"
 			case 2:
-				return '\x05'
+				return "\x05"
 			case 3:
-				return '\x06'
+				return "\x06"
 			}
 		} else {
 			switch c {
 			case 0:
-				return '*'
+				return "*"
 			case 1:
-				return '^'
+				return "^"
 			case 2:
-				return '%'
+				return "%"
 			case 3:
-				return '$'
+				return "$"
 			}
 		}
 	}
-	return '?'
+	return "?"
 }
 
-func BackSymbol(level int) rune {
+func BackSymbol(level int) string {
 	if level == 0 {
-		return ' '
+		return " "
 	}
 	if door.Unicode {
 		switch level {
 		case 1:
-			return '\u2591'
+			return "\u2591"
 		case 2:
-			return '\u2592'
+			return "\u2592"
 		case 3:
-			return '\u2593'
+			return "\u2593"
 		case 4:
-			return '\u2588'
+			return "\u2588"
 		}
 	} else {
 		switch level {
 		case 1:
-			return '\xb0'
+			return "\xb0"
 		case 2:
-			return '\xb1'
+			return "\xb1"
 		case 3:
-			return '\xb2'
+			return "\xb2"
 		case 4:
-			return '\xdb'
+			return "\xdb"
 		}
 	}
-	return '?'
+	return "?"
 }
 
 func GetRank(c int) int {
@@ -363,3 +354,11 @@ func MakeCardStates(decks int) []DeckType {
 	// defaults to 0
 	return result
 }
+
+func RemoveCard(c int, off_x int, off_y int, left bool, right bool) string {
+	Pos := &CardPos[c]
+	if Pos.Level > 1 {
+		Pos.Level--
+	}
+	return ""
+}

+ 9 - 1
playcards.go

@@ -716,8 +716,16 @@ Next_Hand:
 							var right bool = false
 
 							for _, c := range check {
-
+								blk := Blocks[c]
+								if blk[0] == pc.Select_card {
+									right = true
+								}
+								if blk[1] == pc.Select_card {
+									left = true
+								}
 							}
+
+							RemoveCard(pc.Select_card, pc.Off_X, pc.Off_Y, left, right)
 						}
 					}
 				}