Last active
June 11, 2018 10:49
-
-
Save ginxx009/a11df33a6065739f234be37405e623f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using System; | |
using NUnit.Framework.Constraints; | |
using UnityEditorInternal; | |
namespace PaulKevin | |
{ | |
public class BaccaratScoreBoard | |
{ | |
const int MAX = 104; // = 8 decks * 52 cards / 4cardsoneround | |
const int Y = 6; | |
const int X = MAX; | |
const int PLAYER = 1; | |
const int BANKER = 2; | |
const int TIE = 3; | |
const int PLAYER_PAIR = 10; | |
const int BANKER_PAIR = 1; | |
private int m_lastCnt; | |
int[,] arrayBigRoad = new int[Y, X]; | |
int[,] arrayBigEyeRoad = new int[Y, X]; | |
int[,] arraySmallRoad = new int[Y, X]; | |
int[,] arrayCockroach = new int[Y, X]; | |
public BaccaratScoreBoard() | |
{ | |
m_lastCnt = 0; | |
} | |
public void Init() | |
{ | |
//clear the array after using | |
Array.Clear(arrayBigRoad, 0, arrayBigRoad.Length); | |
Array.Clear(arrayBigEyeRoad, 0, arrayBigEyeRoad.Length); | |
Array.Clear(arraySmallRoad, 0, arraySmallRoad.Length); | |
Array.Clear(arrayCockroach, 0, arrayCockroach.Length); | |
} | |
public int[,] GetBigRoad(int xl) | |
{ | |
int ex = 0; | |
int s = 0; | |
for (int i = 0; i < arrayBigRoad.GetLength(1); i++) | |
{ | |
if (arrayBigRoad[0, i] == 0) | |
{ | |
ex = i; | |
break; | |
} | |
} | |
// ex = 10 ---> length == 11 , xl = 12 | |
// ex = 11 ---> length == 12 , xl = 12 | |
// ex = 12 ---> length == 13 , xl = 12 | |
// ex = 13 ---> length == 14 , xl = 12 | |
if (ex <= xl - 1) | |
{ | |
s = 0; | |
} | |
else | |
{ | |
s = ex - (xl - 1); | |
} | |
int[,] arrayBigRoadResult = new int[6, xl]; | |
//copy manually the element references inside array | |
for (int i = 0; i < 6; i++) | |
{ | |
for (int j = 0; j < xl; j++) | |
{ | |
arrayBigRoadResult[i, j] = arrayBigRoad[i, j + s]; | |
} | |
} | |
return arrayBigRoadResult; | |
} | |
public int[,] GetBigEyeRoad(int xl) | |
{ | |
int ex = 0; | |
int s = 0; | |
for (int i = 0; i < arrayBigEyeRoad.GetLength(1); i++) | |
{ | |
if (arrayBigEyeRoad[0, i] == 0) | |
{ | |
ex = i; | |
break; | |
} | |
} | |
// ex = 10 ---> length == 11 , xl = 12 | |
// ex = 11 ---> length == 12 , xl = 12 | |
// ex = 12 ---> length == 13 , xl = 12 | |
// ex = 13 ---> length == 14 , xl = 12 | |
if (ex <= xl - 1) | |
{ | |
s = 0; | |
} | |
else | |
{ | |
s = ex - (xl - 1); | |
} | |
int[,] arrayBigEyeRoadResult = new int[6, xl]; | |
//copy manually the element references inside array | |
for (int i = 0; i < 6; i++) | |
{ | |
for (int j = 0; j < xl; j++) | |
{ | |
arrayBigEyeRoadResult[i, j] = arrayBigEyeRoad[i, j + s]; | |
} | |
} | |
return arrayBigEyeRoadResult; | |
} | |
public int[,] GetSmallRoad(int xl) | |
{ | |
int ex = 0; | |
int s = 0; | |
for (int i = 0; i < arraySmallRoad.GetLength(1); i++) | |
{ | |
if (arraySmallRoad[0, i] == 0) | |
{ | |
ex = i; | |
break; | |
} | |
} | |
// ex = 10 ---> length == 11 , xl = 12 | |
// ex = 11 ---> length == 12 , xl = 12 | |
// ex = 12 ---> length == 13 , xl = 12 | |
// ex = 13 ---> length == 14 , xl = 12 | |
if (ex <= xl - 1) | |
{ | |
s = 0; | |
} | |
else | |
{ | |
s = ex - (xl - 1); | |
} | |
int[,] arraySmallRoadResult = new int[6, xl]; | |
//copy manually the element references inside array | |
for (int i = 0; i < 6; i++) | |
{ | |
for (int j = 0; j < xl; j++) | |
{ | |
arraySmallRoadResult[i, j] = arraySmallRoad[i, j + s]; | |
} | |
} | |
return arraySmallRoadResult; | |
} | |
public int[,] GetCockroach(int xl) | |
{ | |
int ex = 0; | |
int s = 0; | |
for (int i = 0; i < arrayCockroach.GetLength(1); i++) | |
{ | |
if (arrayCockroach[0, i] == 0) | |
{ | |
ex = i; | |
break; | |
} | |
} | |
// ex = 10 ---> length == 11 , xl = 12 | |
// ex = 11 ---> length == 12 , xl = 12 | |
// ex = 12 ---> length == 13 , xl = 12 | |
// ex = 13 ---> length == 14 , xl = 12 | |
if (ex <= xl - 1) | |
{ | |
s = 0; | |
} | |
else | |
{ | |
s = ex - (xl - 1); | |
} | |
int[,] arrayCockroachResult = new int[6, xl]; | |
//copy manually the element references inside array | |
for (int i = 0; i < 6; i++) | |
{ | |
for (int j = 0; j < xl; j++) | |
{ | |
arrayCockroachResult[i, j] = arrayCockroach[i, j + s]; | |
} | |
} | |
return arrayCockroachResult; | |
} | |
public void makeBigRoad(string history) | |
{ | |
string[] arrPartStr = history.Split(','); | |
int[] arrPart = new int[arrPartStr.Length]; | |
for (int c = 0; c < arrPart.Length; c++) | |
{ | |
int temp = 0; | |
if (arrPartStr[c][0] == 'P') temp = 100; | |
else if (arrPartStr[c][0] == 'B') temp = 200; | |
else temp = 300; | |
if (arrPartStr[c][1] == 'P') temp += 10; | |
if (arrPartStr[c][2] == 'P') temp += 1; | |
arrPart[c] = temp; | |
} | |
//TODO FIXED TOMORROW NEED TO CREATE METHOD | |
//string[] arrP | |
// art = new string[] { }; | |
//int[] arrPart = new int[]; | |
//int temp = 0; | |
//sb._StringBuilder(history, arrPart, arrPart, temp); | |
//var strTmp : String = strData; | |
//strTmp = "311|101|211|211|211|211|211|211|211|211|111|111|111|111|111|111|111|111|111" | |
//strTmp = strData.replace(/:/g,""); | |
int i = 0; | |
int intTmp_Ori = 0; //결과값 저장용 (100,200,300) | |
int intTmp = 0; //결과값 저장용 (10,20,30,11,22,33...) | |
int intTmp2 = 0; //타이 횟수 저장용 | |
int intTmp_F = 0; //이전 결과값 대조용(1,2,3) | |
bool bNextMove = false; | |
bool bFirstTie = false; | |
bool bOverLine = false; //6칸이 넘어갔음... | |
bool bOverHeng = false; //다음칸에 값이 있음... | |
int nArray1 = 0; //레코드... | |
int nArray2 = 0; //콜롬... | |
int nArray3 = 0; //콜롬 6칸이 넘어간 거에 대한 임시값... | |
int tmpData; | |
int intCount1 = 0; | |
int intCount2 = 0; | |
intTmp_Ori = arrPart[0]; | |
intTmp = 10 * (intTmp_Ori / 100) + 0; | |
string tmpPoint = ""; | |
for (i = 0; i < arrPart.Length; i++) //히스토리 만큼 돌린다... | |
{ | |
if (i == 0) //첫번째 히스토리면... | |
{ | |
if ((int)(arrPart[i] / 100) != TIE) | |
{ | |
intTmp_F = (int)(intTmp_Ori / 100); | |
} | |
else | |
{ | |
intTmp2++; | |
intTmp_F = (int)(intTmp_Ori / 100); | |
bFirstTie = true; | |
} | |
bNextMove = false; | |
} | |
else //두번째 부터... | |
{ | |
if (bFirstTie) //첫번째 Tie | |
{ | |
if ((int)(arrPart[i] / 100) == TIE) //타이.... | |
{ | |
if (intTmp2 < 6) intTmp2++; //타이 횟수... 늘려준다.. | |
bFirstTie = true; | |
} | |
else | |
{ | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = 10 * (int)(intTmp_Ori / 100) + intTmp2; | |
intTmp_F = (int)(intTmp_Ori / 100); | |
bFirstTie = false; | |
} | |
bNextMove = false; | |
} | |
else | |
{ | |
if ((int)(arrPart[i] / 100) == TIE) //타이.... | |
{ | |
if (intTmp2 < 6) intTmp2++; //타이 횟수... 늘려준다.. | |
intTmp = 10 * (int)(intTmp_Ori / 100) + intTmp2; | |
bNextMove = false; | |
} | |
else if ((int)((int)(arrPart[i]) / 100) != intTmp_F && intTmp_F != TIE) //이전 결과값과 다르면... | |
{ | |
nArray1++; //다음레코드으로 이동 | |
//초기화 | |
nArray2 = 0; | |
nArray3 = 0; | |
intTmp2 = 0; | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = 10 * (int)(intTmp_Ori / 100) + 0; | |
intTmp_F = (int)(intTmp_Ori / 100); | |
bNextMove = false; | |
bOverLine = false; | |
bOverHeng = false; | |
} | |
else if ((int)((int)(arrPart[i]) / 100) == intTmp_F || intTmp_F == TIE) //이전 결과와 같다면... | |
{ | |
if (intTmp_F == 3) nArray2--; | |
bNextMove = true; | |
intTmp2 = 0; | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = 10 * (int)(intTmp_Ori / 100) + 0; | |
intTmp_F = (int)(intTmp_Ori / 100); | |
} | |
} | |
} | |
if (bNextMove) nArray2++; | |
//다음칸에 이미 객체가 있거나 6칸을 넘겼다면... | |
if (nArray2 > 5 && !bOverLine) bOverLine = true; | |
if (bOverLine) | |
{ | |
if (nArray3 == 0) | |
{ | |
nArray3 = nArray1 + 1; | |
} | |
else | |
{ | |
nArray3++; | |
} | |
if (bNextMove) //줄 이동을 취소 시키자 | |
nArray2--; | |
else //칸 이동을 취소 시키자. | |
nArray3--; | |
//arrayBigRoad[nArray2][nArray3] = intTmp; | |
arrayBigRoad[nArray2, nArray3] = (intTmp * 100) + (intTmp_Ori % 100); | |
intCount2 = nArray3; | |
//tmpPoint += '[*' + nArray3 + ',' + nArray2 + '],'; | |
} | |
else //커서 그대로... | |
{ | |
tmpData = (int)(arrayBigRoad[nArray2, nArray1]); | |
if (tmpData != 0 && bNextMove == true && !bOverHeng) bOverHeng = true; | |
if (bOverHeng) | |
{ | |
if (nArray2 <= 0) | |
nArray2 = 0; | |
if (nArray3 == 0) | |
{ | |
nArray3 = nArray1 + 1; | |
} | |
else | |
{ | |
nArray3++; | |
} | |
if (bNextMove) | |
{ | |
if (nArray2 > 0) nArray2--; | |
} | |
else | |
nArray3--; | |
//arrayBigRoad[nArray][nArray3] = intTmp; | |
arrayBigRoad[nArray2, nArray3] = (intTmp * 100) + (intTmp_Ori % 100); | |
intCount2 = nArray3; | |
//tmpPoint += '*[' + nArray3 + ',' + nArray2 + '],'; | |
} | |
else | |
{ | |
//arrayBigRoad[nArray2][nArray1] = intTmp; | |
arrayBigRoad[nArray2, nArray1] = (intTmp * 100) + (intTmp_Ori % 100); | |
intCount2 = nArray1; | |
//tmpPoint += '[' + nArray1 + ',' + nArray2 + '],'; | |
} | |
} | |
intCount1 = nArray2; | |
} | |
} //Big Road | |
public void makeBigEyeRoad(string history) // Big Eye Road | |
{ | |
string[] arrPartStr = history.Split(','); | |
int[] arrPart = new int[arrPartStr.Length]; | |
for (int c = 0; c < arrPart.Length; c++) | |
{ | |
int temp = 0; | |
if (arrPartStr[c][0] == 'P') temp = PLAYER * 100; | |
else if (arrPartStr[c][0] == 'B') temp = BANKER * 100; | |
else temp = 300; | |
if (arrPartStr[c][1] == 'P') temp += PLAYER_PAIR; | |
if (arrPartStr[c][2] == 'P') temp += BANKER_PAIR; | |
arrPart[c] = temp; | |
} | |
int[,] arrTmp = new int[MAX, MAX]; | |
for (int arrTmpx = 0; arrTmpx < arrTmp.GetLength(0); arrTmpx++) | |
{ | |
for (int arrTmpy = 0; arrTmpy < arrTmp.GetLength(1); arrTmpy++) | |
{ | |
arrTmp[arrTmpx, arrTmpy] = -1; // think -1 as undefined. | |
} | |
} | |
int i = 0; | |
int intTmp_Ori = 0; //For storing the result value (100,200,300) | |
int intTmp = 0; //For storing the result value (1,2,3) | |
bool bNextMove = false; | |
int nArray1 = 0; //record | |
int nArray2 = 0; //Column | |
intTmp_Ori = arrPart[0]; | |
intTmp = intTmp_Ori / 100; | |
for (i = 0; i < arrPart.Length; i++) //Turns history | |
{ | |
if (i == 0) //If it's your first history | |
{ | |
intTmp_Ori = (int)(arrPart[i]); //Save current value | |
intTmp = (int)(intTmp_Ori / 100); //P,B,T Value | |
bNextMove = false; | |
} | |
else //From the second | |
{ | |
if ((int)((int)(arrPart[i]) / 100) == TIE) //Tie | |
{ | |
bNextMove = false; | |
} | |
else if ((int)((int)(arrPart[i]) / 100) != intTmp && intTmp != TIE) //Unlike previous result | |
{ | |
nArray1++; //Go to next record | |
//reset | |
nArray2 = 0; | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = (int)(intTmp_Ori / 100); | |
bNextMove = false; | |
} | |
else if ((int)((int)(arrPart[i]) / 100) == intTmp || intTmp == TIE) //If it is the same as the previous result. | |
{ | |
if (intTmp == TIE) nArray2--; | |
bNextMove = true; | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = (int)(intTmp_Ori / 100); | |
} | |
} | |
if (bNextMove) nArray2++; | |
arrTmp[nArray2, nArray1] = intTmp; | |
} | |
//Rcount is 51 | |
int[] arrResult11 = new int[MAX]; //왼쪽값 저장용1 | |
int[] arrResult12 = new int[MAX]; //오른쪽값 비교용 | |
int[] arrResult13 = new int[MAX]; //청,홍에 결과에 대한 배열값(1,2).... | |
int BfResult = 0; | |
int xx = 0; | |
int yy = 0; //가로, 세로... | |
int zz = 0; //칸수를 넘어간넘 처리하자... | |
int x = 0; | |
int y = 0; | |
int xxx = 0; | |
int xStart = 0; | |
int yStart = 0; | |
int yLastp = 0; | |
int RCount = 0; | |
int nStart = 0; | |
int nEnd = 0; | |
int intData = 0; | |
int tmpData = 0; | |
int intCount1 = 0; | |
int intCount2 = 0; | |
int undefined = -1; | |
if ((nArray1 > 0 && nArray2 > 0) || nArray1 > 1) //2번째칸 2번째줄부터 시작됨... | |
{ | |
if (arrTmp[1, 1] != undefined) | |
{ | |
xStart = 1; | |
yStart = 1; | |
} | |
else | |
{ | |
xStart = 2; | |
yStart = 0; | |
} | |
//1차 배열.... | |
for (x = xStart; x <= nArray1; x++) //레코드... | |
{ | |
//6 here for the field | |
for (y = yStart; y < MAX; y++) //필드 | |
{ | |
if (RCount == 0) //첫번째 칸은 무조건 옆에거랑 비교해라... | |
{ | |
if (arrTmp[y, x - 1] != undefined) | |
{ | |
//홍 | |
arrResult11[RCount] = 2; | |
arrResult12[RCount] = 2; | |
arrResult13[RCount] = 2; | |
} | |
else | |
{ | |
//청 | |
arrResult11[RCount] = 1; | |
arrResult12[RCount] = 2; | |
arrResult13[RCount] = 1; | |
} | |
} | |
else | |
{ | |
if (arrTmp[y, x] == undefined) //다음칸으로 이동 되기전에 검사한다.. | |
{ | |
yLastp = y; | |
yStart = 0; | |
break; //다음 라인으로 넘어갈것... | |
} | |
if (y == 0) //다음칸 첫번째 는.... | |
{ | |
if (arrTmp[yLastp, x - 2] != undefined) //새로운 칸으로 넘어갔으나, 왼쪽칸 다음에 값이 있으면.... | |
{ | |
arrResult11[RCount] = 2; //홍 | |
arrResult12[RCount] = 1; //청 | |
} | |
else | |
{ | |
arrResult11[RCount] = 2; //홍 | |
arrResult12[RCount] = 2; //홍 | |
} | |
} | |
else | |
{ | |
if (arrTmp[y, x - 1] != undefined) | |
{ | |
arrResult11[RCount] = 2; //홍 | |
arrResult12[RCount] = 2; //홍 | |
} | |
else | |
{ | |
arrResult11[RCount] = 1; //청 | |
arrResult12[RCount] = 2; //홍 | |
} | |
} | |
if (arrResult11[RCount - 1] == 2 && arrResult12[RCount - 1] == 1) //이전 내용이 홍-청 의 경우... | |
{ | |
if (arrResult11[RCount] == 2 && arrResult12[RCount] == 2) //현재 홍-홍 일땐... | |
arrResult13[RCount] = 2; | |
else | |
arrResult13[RCount] = 1; | |
} | |
else if (arrResult11[RCount] == arrResult11[RCount - 1] && arrResult12[RCount] == arrResult12[RCount - 1]) | |
{ | |
arrResult13[RCount] = 2; | |
} | |
else | |
{ | |
arrResult13[RCount] = 1; | |
} | |
} | |
RCount++; | |
} | |
} | |
//1군 결과를 2차 배열로 저장한다.... | |
for (i = 0; i < RCount; i++) //히스토리 만큼 돌린다... | |
{ | |
if (i == 0) | |
{ | |
xx = 0; | |
yy = 0; | |
zz = 0; | |
} | |
else if ((int)(arrResult13[i]) != BfResult) //이전 결과값과 다르면... | |
{ | |
xx++; //다음레코드으로 이동 | |
yy = 0; | |
zz = 0; | |
} | |
else //이전 결과와 같다면... | |
{ | |
yy++; | |
} | |
BfResult = (int)(arrResult13[i]); | |
if (yy > 5) //필드가 6보다 많다면... | |
{ | |
} | |
else | |
{ | |
tmpData = (int)(arrayBigEyeRoad[yy, xx]); | |
} | |
if (yy > 5) //필드가 6보다 많다면... | |
{ | |
yy--; | |
if (zz == 0) | |
{ | |
zz = xx + 1; | |
} | |
else | |
{ | |
zz++; | |
} | |
} | |
else if (tmpData != 0) | |
{ | |
yy--; | |
if (yy == 0) | |
{ | |
zz = xx++; | |
} | |
else | |
{ | |
if (zz == 0) | |
{ | |
zz = xx + 1; | |
} | |
else | |
{ | |
zz++; | |
} | |
} | |
} | |
else | |
{ | |
zz = xx; | |
} | |
arrayBigEyeRoad[yy, zz] = BfResult; | |
intCount1 = yy; | |
intCount2 = zz; | |
} | |
} | |
} | |
public void makeSmallRoad(string history) //Small Road | |
{ | |
string[] arrPartStr = history.Split(','); | |
int[] arrPart = new int[arrPartStr.Length]; | |
for (int c = 0; c < arrPart.Length; c++) | |
{ | |
int temp = 0; | |
if (arrPartStr[c][0] == 'P') temp = 100; | |
else if (arrPartStr[c][0] == 'B') temp = 200; | |
else temp = 300; | |
if (arrPartStr[c][1] == 'P') temp += 10; | |
if (arrPartStr[c][2] == 'P') temp += 1; | |
arrPart[c] = temp; | |
} | |
int[,] arrTmp = new int[MAX, MAX]; | |
for (int arrTmpx = 0; arrTmpx < arrTmp.GetLength(0); arrTmpx++) | |
{ | |
for (int arrTmpy = 0; arrTmpy < arrTmp.GetLength(1); arrTmpy++) | |
{ | |
arrTmp[arrTmpx, arrTmpy] = -1; // think -1 as undefined. | |
} | |
} | |
int i = 0; | |
int intTmp_Ori = 0; //For storing the result value (100,200,300) | |
int intTmp = 0; //For storing the result value (1,2,3) | |
bool bNextMove = false; | |
int nArray1 = 0; //record | |
int nArray2 = 0; //Column | |
intTmp_Ori = arrPart[0]; | |
intTmp = intTmp_Ori / 100; | |
for (i = 0; i < arrPart.Length; i++) //Turns history | |
{ | |
if (i == 0) //If it's your first history | |
{ | |
intTmp_Ori = (int)(arrPart[i]); //Save current value | |
intTmp = (int)(intTmp_Ori / 100); //P,B,T Value | |
bNextMove = false; | |
} | |
else //From the second | |
{ | |
if ((int)((int)(arrPart[i]) / 100) == TIE) //Tie | |
{ | |
bNextMove = false; | |
} | |
else if ((int)((int)(arrPart[i]) / 100) != intTmp && intTmp != TIE)//Unlike previous result | |
{ | |
nArray1++; //Go to next record | |
//reset | |
nArray2 = 0; | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = (int)(intTmp_Ori / 100); | |
bNextMove = false; | |
} | |
else if ((int)((int)(arrPart[i]) / 100) == intTmp || intTmp == TIE)//If it is the same as the previous result. | |
{ | |
if (intTmp == 3) nArray2--; | |
bNextMove = true; | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = (int)(intTmp_Ori / 100); | |
} | |
} | |
if (bNextMove) nArray2++; | |
arrTmp[nArray2, nArray1] = intTmp; | |
} | |
int[] arrResult21 = new int[MAX]; | |
int[] arrResult22 = new int[MAX]; | |
int[] arrResult23 = new int[MAX]; | |
int BfResult = 0; | |
int xx = 0; | |
int yy = 0; | |
int zz = 0; | |
int x = 0; | |
int y = 0; | |
int xxx = 0; | |
int xStart = 0; | |
int yStart = 0; | |
int yLastp = 0; | |
int RCount = 0; | |
int nStart = 0; | |
int nEnd = 0; | |
int intData = 0; | |
int intCount1 = 0; | |
int intCount2 = 0; | |
int undefined = -1; | |
int tmpData = 0; | |
if ((nArray1 > 1 && nArray2 > 0) || nArray1 > 2) //3번째칸 2번째줄부터 시작됨... | |
{ | |
if (arrTmp[1, 2] != undefined) | |
{ | |
xStart = 2; | |
yStart = 1; | |
} | |
else | |
{ | |
xStart = 3; | |
yStart = 0; | |
} | |
//1차 배열.... | |
for (x = xStart; x <= nArray1; x++) //레코드... | |
{ | |
for (y = yStart; y < MAX; y++) //필드 | |
{ | |
if (RCount == 0) //첫번째 칸은 무조건 옆에거랑 비교해라... | |
{ | |
if (arrTmp[y, x - 2] != undefined) | |
{ | |
//홍 | |
arrResult21[RCount] = 2; | |
arrResult22[RCount] = 2; | |
arrResult23[RCount] = 2; | |
} | |
else | |
{ | |
//청 | |
arrResult21[RCount] = 1; | |
arrResult22[RCount] = 2; | |
arrResult23[RCount] = 1; | |
} | |
} | |
else | |
{ | |
if (arrTmp[y, x] == undefined) //다음칸으로 이동 되기전에 검사한다.. | |
{ | |
yLastp = y; | |
yStart = 0; | |
break; //다음 라인으로 넘어갈것... | |
} | |
if (y == 0) //다음칸 첫번째 는.... | |
{ | |
if (arrTmp[yLastp, x - 3] != undefined) //새로운 칸으로 넘어갔으나, 왼쪽칸 다음에 값이 있으면.... | |
{ | |
arrResult21[RCount] = 2; | |
arrResult22[RCount] = 1; | |
} | |
else | |
{ | |
arrResult21[RCount] = 2; | |
arrResult22[RCount] = 2; | |
} | |
} | |
else | |
{ | |
if (arrTmp[y, x - 2] != undefined) | |
{ | |
arrResult21[RCount] = 2; | |
arrResult22[RCount] = 2; | |
} | |
else | |
{ | |
arrResult21[RCount] = 1; | |
arrResult22[RCount] = 2; | |
} | |
} | |
if (arrResult21[RCount - 1] == 2 && arrResult22[RCount - 1] == 1) //이전 내용이 홍-청 의 경우... | |
{ | |
if (arrResult21[RCount] == 2 && arrResult22[RCount] == 2) //현재 홍-홍 일땐... | |
arrResult23[RCount] = 2; | |
else | |
arrResult23[RCount] = 1; | |
} | |
else if (arrResult21[RCount] == arrResult21[RCount - 1] && arrResult22[RCount] == arrResult22[RCount - 1]) | |
{ | |
arrResult23[RCount] = 2; | |
} | |
else | |
{ | |
arrResult23[RCount] = 1; | |
} | |
} | |
RCount++; | |
} | |
} | |
//2군 결과를 2차 배열로 저장한다.... | |
for (i = 0; i < RCount; i++) //히스토리 만큼 돌린다... | |
{ | |
if (i == 0) | |
{ | |
xx = 0; | |
yy = 0; | |
zz = 0; | |
} | |
else if ((int)(arrResult23[i]) != BfResult) //이전 결과값과 다르면... | |
{ | |
xx++; //다음레코드으로 이동 | |
yy = 0; | |
zz = 0; | |
} | |
else //이전 결과와 같다면... | |
{ | |
yy++; | |
} | |
BfResult = (int)(arrResult23[i]); | |
if (yy > 5) //필드가 6보다 많다면... | |
{ | |
} | |
else | |
{ | |
tmpData = (int)(arraySmallRoad[yy, xx]); | |
} | |
if (yy > 5) //필드가 6보다 많다면... | |
{ | |
yy--; | |
if (zz == 0) | |
{ | |
zz = xx + 1; | |
} | |
else | |
{ | |
zz++; | |
} | |
} | |
else if (tmpData != 0) | |
{ | |
yy--; | |
if (yy == 0) | |
{ | |
zz = xx++; | |
} | |
else | |
{ | |
if (zz == 0) | |
{ | |
zz = xx + 1; | |
} | |
else | |
{ | |
zz++; | |
} | |
} | |
} | |
else | |
{ | |
zz = xx; | |
} | |
arraySmallRoad[yy, zz] = BfResult; | |
intCount1 = yy; | |
intCount2 = zz; | |
} | |
} | |
} | |
public void makeCockroachRoad(string history) //CockroachRoad | |
{ | |
string[] arrPartStr = history.Split(','); | |
int[] arrPart = new int[arrPartStr.Length]; | |
for (int c = 0; c < arrPart.Length; c++) | |
{ | |
int temp = 0; | |
if (arrPartStr[c][0] == 'P') temp = 100; | |
else if (arrPartStr[c][0] == 'B') temp = 200; | |
else temp = 300; | |
if (arrPartStr[c][1] == 'P') temp += 10; | |
if (arrPartStr[c][2] == 'P') temp += 1; | |
arrPart[c] = temp; | |
} | |
//20 is the highest possible size | |
int[,] arrTmp = new int[MAX, MAX]; | |
for (int arrTmpx = 0; arrTmpx < arrTmp.GetLength(0); arrTmpx++) | |
{ | |
for (int arrTmpy = 0; arrTmpy < arrTmp.GetLength(1); arrTmpy++) | |
{ | |
arrTmp[arrTmpx, arrTmpy] = -1; // think -1 as undefined. | |
} | |
} | |
int i = 0; | |
int intTmp_Ori = 0; //For storing the result value (100,200,300) | |
int intTmp = 0; //For storing the result value (1,2,3) | |
bool bNextMove = false; | |
int nArray1 = 0; //record | |
int nArray2 = 0; //Column | |
intTmp_Ori = arrPart[0]; | |
intTmp = intTmp_Ori / 100; | |
for (i = 0; i < arrPart.Length; i++) //Turns history | |
{ | |
if (i == 0) //If it's your first history | |
{ | |
intTmp_Ori = (int)(arrPart[i]); //Save current value | |
intTmp = (int)(intTmp_Ori / 100); //P,B,T Value | |
bNextMove = false; | |
} | |
else //From the second | |
{ | |
if ((int)((int)(arrPart[i]) / 100) == TIE) //Tie | |
{ | |
bNextMove = false; | |
} | |
else if ((int)((int)(arrPart[i]) / 100) != intTmp && intTmp != TIE)//Unlike previous result | |
{ | |
nArray1++; //Go to next record | |
//reset | |
nArray2 = 0; | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = (int)(intTmp_Ori / 100); | |
bNextMove = false; | |
} | |
else if ((int)((int)(arrPart[i]) / 100) == intTmp || intTmp == TIE)//If it is the same as the previous result. | |
{ | |
if (intTmp == 3) nArray2--; | |
bNextMove = true; | |
intTmp_Ori = (int)(arrPart[i]); | |
intTmp = (int)(intTmp_Ori / 100); | |
} | |
} | |
if (bNextMove) nArray2++; | |
arrTmp[nArray2, nArray1] = intTmp; | |
} | |
int[] arrResult31 = new int[MAX]; | |
int[] arrResult32 = new int[MAX]; | |
int[] arrResult33 = new int[MAX]; | |
int BfResult = 0; | |
int xx = 0; | |
int yy = 0; //가로, 세로... | |
int zz = 0; | |
int x = 0; | |
int y = 0; | |
int xxx = 0; | |
int xStart = 0; | |
int yStart = 0; | |
int RCount = 0; | |
int nStart = 0; | |
int nEnd = 0; | |
int yLastp = 0; | |
int intData = 0; | |
int intCount1 = 0; | |
int intCount2 = 0; | |
int undefined = -1; | |
int tmpData = 0; | |
if ((nArray1 > 1 && nArray2 > 0) || nArray1 > 2) //3번째칸 2번째줄부터 시작됨... | |
{ | |
if (arrTmp[1, 3] != undefined) | |
{ | |
xStart = 3; | |
yStart = 1; | |
} | |
else | |
{ | |
xStart = 4; | |
yStart = 0; | |
} | |
//1차 배열.... | |
for (x = xStart; x <= nArray1; x++) //레코드... | |
{ | |
for (y = yStart; y < MAX; y++) //필드 | |
{ | |
if (RCount == 0) //첫번째 칸은 무조건 옆에거랑 비교해라... | |
{ | |
if (arrTmp[y, x - 3] != undefined) | |
{ | |
//홍 | |
arrResult31[RCount] = 2; | |
arrResult32[RCount] = 2; | |
arrResult33[RCount] = 2; | |
} | |
else | |
{ | |
//청 | |
arrResult31[RCount] = 1; | |
arrResult32[RCount] = 2; | |
arrResult33[RCount] = 1; | |
} | |
} | |
else | |
{ | |
if (arrTmp[y, x] == undefined) //다음칸으로 이동 되기전에 검사한다.. | |
{ | |
yLastp = y; | |
yStart = 0; | |
break; //다음 라인으로 넘어갈것... | |
} | |
if (y == 0) //다음칸 첫번째 는.... | |
{ | |
if (arrTmp[yLastp, x - 4] != undefined) //새로운 칸으로 넘어갔으나, 왼쪽칸 다음에 값이 있으면.... | |
{ | |
arrResult31[RCount] = 2; | |
arrResult32[RCount] = 1; | |
} | |
else | |
{ | |
arrResult31[RCount] = 2; | |
arrResult32[RCount] = 2; | |
} | |
} | |
else | |
{ | |
if (arrTmp[y, x - 3] != undefined) | |
{ | |
arrResult31[RCount] = 2; | |
arrResult32[RCount] = 2; | |
} | |
else | |
{ | |
arrResult31[RCount] = 1; | |
arrResult32[RCount] = 2; | |
} | |
} | |
if (arrResult31[RCount - 1] == 2 && arrResult32[RCount - 1] == 1) //이전 내용이 홍-청 의 경우... | |
{ | |
if (arrResult31[RCount] == 2 && arrResult32[RCount] == 2) //현재 홍-홍 일땐... | |
arrResult33[RCount] = 2; | |
else | |
arrResult33[RCount] = 1; | |
} | |
else if (arrResult31[RCount] == arrResult31[RCount - 1] && arrResult32[RCount] == arrResult32[RCount - 1]) | |
{ | |
arrResult33[RCount] = 2; | |
} | |
else | |
{ | |
arrResult33[RCount] = 1; | |
} | |
} | |
RCount++; | |
} | |
} | |
//3군 결과를 2차 배열로 저장한다.... | |
for (i = 0; i < RCount; i++) //히스토리 만큼 돌린다... | |
{ | |
if (i == 0) | |
{ | |
xx = 0; | |
yy = 0; | |
zz = 0; | |
} | |
else if ((int)(arrResult33[i]) != BfResult) //이전 결과값과 다르면... | |
{ | |
xx++; //다음레코드으로 이동 | |
yy = 0; | |
zz = 0; | |
} | |
else //이전 결과와 같다면... | |
{ | |
yy++; | |
} | |
BfResult = (int)(arrResult33[i]); | |
if (yy > 5) | |
{ | |
} | |
else | |
{ | |
tmpData = (int)(arrayCockroach[yy, xx]); | |
} | |
if (yy > 5) //필드가 6보다 많다면... | |
{ | |
yy--; | |
if (zz == 0) | |
{ | |
zz = xx + 1; | |
} | |
else | |
{ | |
zz++; | |
} | |
} | |
else if (tmpData != 0) | |
{ | |
yy--; | |
if (yy == 0) | |
{ | |
zz = xx++; | |
} | |
else | |
{ | |
if (zz == 0) | |
{ | |
zz = xx + 1; | |
} | |
else | |
{ | |
zz++; | |
} | |
} | |
} | |
else | |
{ | |
zz = xx; | |
} | |
arrayCockroach[yy, zz] = BfResult; | |
intCount1 = yy; | |
intCount2 = zz; | |
} | |
} | |
} | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using UnityEngine; | |
using PaulKevin; | |
public class Baccarat_BetBoard : MonoBehaviour | |
{ | |
//[SerializeField] protected GameObject[] prefab_big_road = null; | |
//[SerializeField] Transform[] pos_big_road = null; | |
//[SerializeField] protected GameObject[] prefab_small_road = null; | |
//[SerializeField] Transform[] pos_smallroad = null; | |
//[SerializeField] protected GameObject[] prefab_big_eye_road = null; | |
//[SerializeField] Transform[] pos_big_eye_road = null; | |
//[SerializeField] protected GameObject[] prefab_cockroach_road = null; | |
//[SerializeField] Transform[] pos_cockroach_road = null; | |
//[SerializeField] protected GameObject[] prefab_bead_road = null; | |
//[SerializeField] Transform[] pos_bead_road = null; | |
public BaccaratScoreBoard bsb; | |
public void Start() | |
{ | |
bsb = new BaccaratScoreBoard(); | |
} | |
public void OnEnable() | |
{ | |
NetworkManager.instance.WebSocketServer.OnCallBack_SC_WEBSOCKET_BcSetGameCommand += CallBack_CS_WEBSOCKET_BcSetGameCommand; | |
NetworkManager.instance.WebSocketServer.OnCallBack_SC_WEBSOCKET_BcGametableHistory += CallBack_SC_WEBSOCKET_BcGametableHistory; | |
} | |
public void OnDisable() | |
{ | |
NetworkManager.instance.WebSocketServer.OnCallBack_SC_WEBSOCKET_BcSetGameCommand -= CallBack_CS_WEBSOCKET_BcSetGameCommand; | |
NetworkManager.instance.WebSocketServer.OnCallBack_SC_WEBSOCKET_BcGametableHistory -= CallBack_SC_WEBSOCKET_BcGametableHistory; | |
} | |
private void CallBack_CS_WEBSOCKET_BcSetGameCommand(bool success, Int32 table_no, Int32 gametable_no, Int64 game_no, Int32 shoe_no, Int32 round_no, Int32 command, Int32 gap) | |
{ | |
switch ((GameCommon.GAMEBC_COMMAND)command) | |
{ | |
case GameCommon.GAMEBC_COMMAND.end: | |
// //SEND THE PACKET | |
// //ORIGINAL CODE | |
NetworkManager.Instance.WebSocketServer.CS_WEBSOCKET_BcGametableHistory(gametable_no, 0, 0, 0, 0); | |
break; | |
} | |
} | |
private void CallBack_SC_WEBSOCKET_BcGametableHistory(bool success, Int32 gametable_no, Int32 year, Int32 month, Int32 day, Int32 shoe_no, bc_gametable_history_list list) | |
{ | |
string newString = ""; | |
for (int i = 0; i < tzPlayInfo.Instance.bc_gametable_history_list.Count; i++) | |
{ | |
newString += tzPlayInfo.Instance.bc_gametable_history_list[i].r; | |
newString += ","; | |
} | |
newString = newString.TrimEnd(','); | |
bsb.Init(); | |
bsb.makeBigRoad(newString); | |
tzPlayInfo.Instance.Arrbsb[gametable_no].ArrBigRoad = bsb.GetBigRoad(12); | |
bsb.makeBigEyeRoad(newString); | |
tzPlayInfo.Instance.Arrbsb[gametable_no].ArrBigEyeRoad = bsb.GetBigEyeRoad(12); | |
bsb.makeSmallRoad(newString); | |
tzPlayInfo.Instance.Arrbsb[gametable_no].ArrSmallRoad = bsb.GetSmallRoad(12); | |
bsb.makeCockroachRoad(newString); | |
tzPlayInfo.Instance.Arrbsb[gametable_no].ArrCockroachRoad = bsb.GetCockroach(12); | |
string road1 = ""; | |
for (int y = 0; y < tzPlayInfo.Instance.Arrbsb[gametable_no].ArrBigRoad.GetLength(0); y++) | |
{ | |
for (int x = 0; x < tzPlayInfo.Instance.Arrbsb[gametable_no].ArrBigRoad.GetLength(1); x++) | |
{ | |
road1 += string.Format("{0:D2}", tzPlayInfo.Instance.Arrbsb[gametable_no].ArrBigRoad[y, x] / 100); | |
road1 += "."; | |
} | |
road1 += "\n"; | |
} | |
Debug.Log(road1); | |
string road2 = ""; | |
for (int y = 0; y < tzPlayInfo.Instance.Arrbsb[gametable_no].ArrBigEyeRoad.GetLength(0); y++) | |
{ | |
for (int x = 0; x < tzPlayInfo.Instance.Arrbsb[gametable_no].ArrBigEyeRoad.GetLength(1); x++) | |
{ | |
road2 += string.Format("{0:D2}", tzPlayInfo.Instance.Arrbsb[gametable_no].ArrBigEyeRoad[y, x]); | |
road2 += "."; | |
} | |
road2 += "\n"; | |
} | |
Debug.Log(road2); | |
string road3 = ""; | |
for (int y = 0; y < tzPlayInfo.Instance.Arrbsb[gametable_no].ArrSmallRoad.GetLength(0); y++) | |
{ | |
for (int x = 0; x < tzPlayInfo.Instance.Arrbsb[gametable_no].ArrSmallRoad.GetLength(1); x++) | |
{ | |
road3 += string.Format("{0:D2}", tzPlayInfo.Instance.Arrbsb[gametable_no].ArrSmallRoad[y, x]); | |
road3 += "."; | |
} | |
road3 += "\n"; | |
} | |
Debug.Log(road3); | |
string road4 = ""; | |
for (int y = 0; y < tzPlayInfo.Instance.Arrbsb[gametable_no].ArrCockroachRoad.GetLength(0); y++) | |
{ | |
for (int x = 0; x < tzPlayInfo.Instance.Arrbsb[gametable_no].ArrCockroachRoad.GetLength(1); x++) | |
{ | |
road4 += string.Format("{0:D2}", tzPlayInfo.Instance.Arrbsb[gametable_no].ArrCockroachRoad[y, x]); | |
road4 += "."; | |
} | |
road4 += "\n"; | |
} | |
Debug.Log(road4); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment