private int insCounter(string url) { var count = counterHash.Int(url) + 1; counterHash[url] = count; return(count); }
public void Should_update_document_with_ifMatch() { var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary <string, object>() .String("foo", "some other new string") .Int("bar", 54321) .Int("baz", 12345); var updateResult = db.Document .IfMatch(documents[0].Rev()) .Update(documents[0].ID(), document); Assert.AreEqual(202, updateResult.StatusCode); Assert.IsTrue(updateResult.Success); Assert.IsTrue(updateResult.HasValue); Assert.AreEqual(updateResult.Value.ID(), documents[0].ID()); Assert.AreEqual(updateResult.Value.Key(), documents[0].Key()); Assert.AreNotEqual(updateResult.Value.Rev(), documents[0].Rev()); var getResult = db.Document .Get(updateResult.Value.ID()); Assert.AreEqual(getResult.Value.ID(), updateResult.Value.ID()); Assert.AreEqual(getResult.Value.Key(), updateResult.Value.Key()); Assert.AreEqual(getResult.Value.Rev(), updateResult.Value.Rev()); Assert.AreNotEqual(getResult.Value.String("foo"), documents[0].String("foo")); Assert.AreEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreNotEqual(getResult.Value.Int("bar"), documents[0].Int("bar")); Assert.AreEqual(getResult.Value.Int("bar"), document.Int("bar")); Assert.AreEqual(getResult.Value.Int("baz"), document.Int("baz")); }
public void Show(Dictionary <string, object> dict) { Name.text = dict.String("winner"); if (dict.String("winnerid") == GameData.Shared.Uid) { Name.color = MaterialUI.MaterialColor.cyanA200; } else { Name.color = Color.white; } // 分数 var score = dict.Int("score"); Score.text = _.Num2CnDigit(score, true); Score.color = _.GetTextColor(score); // 底池 Pot.text = _.Num2CnDigit(dict.Int("pot")); // 牌型 var desc = Card.GetCardDesc(dict.Int("maxFiveRank")); var cardTypeParent = CardType.transform.parent.gameObject; if (string.IsNullOrEmpty(desc)) { cardTypeParent.SetActive(false); } else { cardTypeParent.SetActive(true); CardType.text = desc; } //omaha特殊处理 bool isOmaha = GameData.Shared.Type.Value == GameType.Omaha; CardContainers[2].gameObject.SetActive(isOmaha); CardContainers[3].gameObject.SetActive(isOmaha); HandCardsParent.spacing = isOmaha ? -46 : 6; // 手牌 var cards = dict.IL("cards"); if (cards.Count <= 0) { foreach (var card in CardContainers) { card.CardInstance.Turnback(); } return; } for (int i = 0; i < cards.Count; i++) { CardContainers[i].CardInstance.Show(cards[i]); } }
public void Init(Dictionary <string, object> gamerMes) { uid = gamerMes.String("uid"); enterLimit = gamerMes.Int("enter_limit") == 1; seatLimit = gamerMes.Int("seat_limit") == 1; talkLimit = gamerMes.Int("talk_limit") == 1; Name.text = gamerMes.String("name"); if (gamerMes.Bool("in_room")) { if (gamerMes.Int("seat") > -1) { State.text = "游戏中"; } else { State.text = "旁观中"; } } EnterLimitImg.color = enterLimit ? Color.white : unlimitCol; SeatLimitImg.color = seatLimit ? Color.white : unlimitCol; TalkLimitImg.color = talkLimit ? Color.white : unlimitCol; GamerAvatar.GetComponent <Avatar>().SetImage(gamerMes.String("avatar")); GamerAvatar.GetComponent <Avatar>().SetAlpha(gamerMes.Bool("in_room")); }
public void Init(Dictionary <string, object> data, int maxPercent) { var player = GameData.Shared.FindPlayer(data.String("uid")); var outsNumber = data.Int("ct"); Name.text = player.Name; //omaha特殊处理 bool isOmaha = GameData.Shared.Type.Value == GameType.Omaha; CardContainers[2].gameObject.SetActive(isOmaha); CardContainers[3].gameObject.SetActive(isOmaha); CardsParent.spacing = isOmaha ? -46 : 8; for (int i = 0; i < player.Cards.Value.Count; i++) { CardContainers[i].CardInstance.Show(player.Cards.Value[i]); } Kind.text = outsNumber.ToString() + "张"; WinRateText.text = data.Int("win_rate") + "%"; string color = data.Int("win_rate") == maxPercent? "#ff1744" : "#868d94"; WinRateText.transform.parent.gameObject.SetActive(maxPercent != -1); WinRateText.transform.parent.GetComponent <ProceduralImage>().color = _.HexColor(color); }
public GameOverJson(Dictionary <string, object> dict) { prize = dict.Int("prize"); chips = dict.Int("chips"); uid = dict.String("uid"); seat = dict.Int("seat"); cards = dict.IL("cards"); maxFiveRank = dict.Int("maxFiveRank"); bury_card = dict.Int("bury_card") == 1; }
public void SetTrust(Dictionary <string, object> trust) { if (trust.ContainsKey("chooseid") && trust.ContainsKey("call")) { var flag = Convert.ToString(trust.Int("chooseid"), 2); var num = trust.Int("call"); Trust.SetDeposit(flag, num); } else { Trust.ShouldShow.Value = false; } }
public void Init(Dictionary <string, object> json) { var rank = json.Int("rank"); var score = json.Int("score"); var isEnd = json.Int("is_end") == 1; var win = json.Int("win"); var award = json.Dict("award").String("award"); this.gameEnd = isEnd; var isDefeat = score == 0 && win == 0; Image _image = GetComponent <Image>(); Animator _animator = GetComponent <Animator>(); //标题 if (isDefeat) { _animator.enabled = false; _image.sprite = BGImgs[1]; TitleMsg.SetActive(false); } else { _animator.enabled = true; _image.sprite = BGImgs[0]; TitleMsg.SetActive(true); bool isMTT = GameData.Shared.Type.Value == GameType.MTT; TitleMsg.transform.GetChild(0).gameObject.SetActive(isMTT); TitleMsg.transform.GetChild(1).localScale = isMTT ? new Vector3(0.5f, 0.5f, 1f) : Vector3.one; } //文字显示 if (score > 0) { SetAward(score + "金币"); } else if (!string.IsNullOrEmpty(award)) { SetAward(award); } else { AwardText.text = "您被淘汰了\n<size=55>调整好状态再来一局吧!</size>"; AwardText.color = new Color(1, 1, 1, 0.6f); } SharePicBtn.SetActive(!isDefeat); StayInRoom.SetActive(!gameEnd); SetRankNum(rank); }
public void Should_create_document_with_returnNew_parameter() { Database.ClearTestCollection(Database.TestDocumentCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary <string, object>() .String("foo", "foo string value") .Int("bar", 12345); var createResult = db.Document .ReturnNew() .Create(Database.TestDocumentCollectionName, document); Assert.AreEqual(202, createResult.StatusCode); Assert.IsTrue(createResult.Success); Assert.IsTrue(createResult.HasValue); Assert.IsTrue(createResult.Value.IsString("_id")); Assert.IsTrue(createResult.Value.IsString("_key")); Assert.IsTrue(createResult.Value.IsString("_rev")); Assert.IsTrue(createResult.Value.Has("new")); Assert.AreEqual(createResult.Value.ID(), createResult.Value.String("new._id")); Assert.AreEqual(createResult.Value.Key(), createResult.Value.String("new._key")); Assert.AreEqual(createResult.Value.Rev(), createResult.Value.String("new._rev")); Assert.AreEqual(document.String("foo"), createResult.Value.String("new.foo")); Assert.AreEqual(document.Int("bar"), createResult.Value.Int("new.bar")); }
public void Should_replace_document_with_waitForSync() { var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary <string, object>() .String("foo", "some other new string") .Int("baz", 54321); var replaceResult = db.Document .WaitForSync(true) .Replace(documents[0].ID(), document); Assert.AreEqual(201, replaceResult.StatusCode); Assert.IsTrue(replaceResult.Success); Assert.IsTrue(replaceResult.HasValue); Assert.AreEqual(replaceResult.Value.ID(), documents[0].ID()); Assert.AreEqual(replaceResult.Value.Key(), documents[0].Key()); Assert.AreNotEqual(replaceResult.Value.Rev(), documents[0].Rev()); var getResult = db.Document .Get(replaceResult.Value.ID()); Assert.AreEqual(getResult.Value.ID(), replaceResult.Value.ID()); Assert.AreEqual(getResult.Value.Key(), replaceResult.Value.Key()); Assert.AreEqual(getResult.Value.Rev(), replaceResult.Value.Rev()); Assert.AreNotEqual(getResult.Value.String("foo"), documents[0].String("foo")); Assert.AreEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.Int("baz"), document.Int("baz")); Assert.IsFalse(getResult.Value.Has("bar")); }
public static void GeneralUsage() { var document = new Dictionary <string, object>() .String("foo", "foo string value") .Int("bar", 12345) .String("embedded.foo", "embedded foo string value"); // document object would look in JSON representation as follows: // { // "foo": "foo string value", // "bar": 12345, // "embedded": { // "foo": "embedded foo string value" // } // } if (document.IsString("foo") && document.IsInt("bar") && document.IsString("embedded.foo")) { var foo = document.String("foo"); var bar = document.Int("bar"); var embeddedFoo = document.String("embedded.foo"); Console.WriteLine("{0}, {1}, {2}", foo, bar, embeddedFoo); } }
public void Should_replace_document_with_ifMatch_and_lastUpdatePolicy() { var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary <string, object>() .String("foo", "some other new string") .Int("baz", 54321); var replaceResult = db.Document .IfMatch("123456789", AUpdatePolicy.Last) .Replace(documents[0].String("_id"), document); Assert.AreEqual(202, replaceResult.StatusCode); Assert.IsTrue(replaceResult.Success); Assert.IsTrue(replaceResult.HasValue); Assert.AreEqual(replaceResult.Value.String("_id"), documents[0].String("_id")); Assert.AreEqual(replaceResult.Value.String("_key"), documents[0].String("_key")); Assert.AreNotEqual(replaceResult.Value.String("_rev"), documents[0].String("_rev")); var getResult = db.Document .Get(replaceResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_id"), replaceResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_key"), replaceResult.Value.String("_key")); Assert.AreEqual(getResult.Value.String("_rev"), replaceResult.Value.String("_rev")); Assert.AreNotEqual(getResult.Value.String("foo"), documents[0].String("foo")); Assert.AreEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.Int("baz"), document.Int("baz")); Assert.IsFalse(getResult.Value.Has("bar")); }
public static void ArraySetGetOperations() { var document = new Dictionary <string, object>() .Array("array1", new int[] { 1, 2, 3 }); var array1 = document.Array <int>("array1"); var array1Size = document.Size("array1"); var item2 = document.Int("array1[1]"); // change value of item at specified index document.Int("array1[1]", 222); for (int i = 0; i < document.Size("array1"); i++) { Console.WriteLine(document.Array <int>("array1")[i]); } Console.WriteLine("Size: " + document.Size("array1")); Console.WriteLine("Item 2: " + document.Int("array1[1]")); }
private void reload(Dictionary <string, object> ret) { totalNumber = ret.Int("total_page"); currentNumber = ret.Int("currentPage"); PageSlider.maxValue = totalNumber; PageSlider.minValue = Mathf.Min(totalNumber, 1); PageSlider.value = currentNumber; Total.text = string.Format("/ {0}", totalNumber); Current.text = currentNumber.ToString(); var list = ret.List("data"); for (int num = 0; num < 10; num++) { if (list.Count > num) { // 复用的部分 var dt = list[num] as Dictionary <string, object>; HoldCardMsg user; if (num < users.Count) { user = users[num]; user.gameObject.SetActive(true); } else { var go = GameObject.Instantiate(HoldCardMsgPrefab, Rect.transform); user = go.GetComponent <HoldCardMsg>(); users.Add(user); } user.Show(dt); } else if (users.Count > num) { // 超出的部分隐藏 users[num].gameObject.SetActive(false); } } }
private string actText(Dictionary <string, object> actDict) { var text = actDict.String("act"); var actNum = actDict.Int("num"); if (actNum != 0) { text += _.Num2CnDigit(actNum); } return(text); }
public void Should_set_long_and_get_int_fields() { var doc1 = new Dictionary <string, object>() .Long("long1", 123L) .List("longList", new List <long> { 1, 2, 3 }) .Array("longArray", new long[] { 4, 5, 6 }) .List("stringList", new List <string> { "7", "8", "9" }); Assert.AreEqual(123, doc1.Int("long1")); Assert.AreEqual(1, doc1.Int("longList[0]")); Assert.AreEqual(2, doc1.Int("longList[1]")); Assert.AreEqual(3, doc1.Int("longList[2]")); Assert.AreEqual(1, doc1.List <int>("longList")[0]); Assert.AreEqual(2, doc1.List <int>("longList")[1]); Assert.AreEqual(3, doc1.List <int>("longList")[2]); Assert.AreEqual(4, doc1.Int("longArray[0]")); Assert.AreEqual(5, doc1.Int("longArray[1]")); Assert.AreEqual(6, doc1.Int("longArray[2]")); Assert.AreEqual(4, doc1.Array <int>("longArray")[0]); Assert.AreEqual(5, doc1.Array <int>("longArray")[1]); Assert.AreEqual(6, doc1.Array <int>("longArray")[2]); Assert.AreEqual(7, doc1.Int("stringList[0]")); Assert.AreEqual(8, doc1.Int("stringList[1]")); Assert.AreEqual(9, doc1.Int("stringList[2]")); Assert.AreEqual(7, doc1.List <int>("stringList")[0]); Assert.AreEqual(8, doc1.List <int>("stringList")[1]); Assert.AreEqual(9, doc1.List <int>("stringList")[2]); }
public static void ListSetGetOperations() { var document = new Dictionary <string, object>() .List("list1", new List <int>() { 1, 2, 3 }); var list1 = document.List <int>("list1"); var list1Size = document.Size("list1"); var item2 = document.Int("list1[1]"); // change value of item at specified index document.Int("list1[1]", 222); // append new value to the list document.Int("list1[*]", 4); document.List <int>("list1").ForEach(x => Console.WriteLine(x)); Console.WriteLine("Size: " + document.Size("list1")); Console.WriteLine("Item 2: " + document.Int("list1[1]")); }
void setNormalText(Dictionary <string, object> data, AchieveModel achieve) { // 手数 Hands.text = achieve.total_hand_count.ToString(); // 入池率 Join.text = _.PercentStr(achieve.entry_hand_percent); // 摊牌率 ShowHand.text = _.PercentStr(achieve.showdown_hand_percent); // 入池胜率 JoinWin.text = _.PercentStr(achieve.entry_win_hand_percent); // 激进度 Aggressive.text = achieve.aggressiveness.ToString(); // 翻前加注 PreRaise.text = _.PercentStr(achieve.pfr_hand_percent); // 再次加注 ThreeBet.text = _.PercentStr(achieve.t_bet_percent); // 持续下注 CBet.text = _.PercentStr(achieve.c_bet_round_percent); enterLimit = data.Int("enter_limit") == 1; seatLimit = data.Int("seat_limit") == 1; talkLimit = data.Int("talk_limit") == 1; }
public static void BasicSetGetOperations() { var document = new Dictionary <string, object>() .String("foo", "string value") .Int("bar", 123) .Long("longBar", 12345) .Object("null", null); // standard get operations var str = document.String("foo"); var number = document.Int("bar"); var longNumber = document.Long("longBar"); var nullObject = document.Object("null"); // values are automatically converted if possible var strNumber = document.String("longBar"); var intNumber = document.Int("longBar"); // generic get operation var bar = document.Object <int>("bar"); Console.WriteLine(bar); }
public void Init(Dictionary <string, object> data) { var users = data.List("users"); for (int i = 0; i < users.Count; i++) { var user = users[i] as Dictionary <string, object>; var userGo = Partners[i]; userGo.GetChild(1).GetComponent <Text>().text = user.String("username"); userGo.GetComponentInChildren <Avatar>().SetImage(user.String("avatar")); userGo.GetChild(2).GetComponent <Text>().text = user.String("total_count"); } Text_RecentRoomCount.text = "近10个牌局两人同桌 <color=#18ffff>" + data.Int("recent_room_count") + "</color> 局"; Text_RecentRoomProfit.text = "近10个同桌牌局盈利率为: <color=#ffca28>" + Math.Round(data.Float("recent_room_profit") * 100, 2) + "%</color>"; Text_TotalRoomProfit.text = "所有同桌牌局总盈利率为: <color=#ffca28>" + Math.Round(data.Float("total_room_profit") * 100, 2) + "%</color>"; }
public void Init(Dictionary <string, object> data) { var code = GameData.Shared.GameCode.Value = data.String("code"); var name = GameData.Shared.RoomName.Value = data.String("name"); avatar.SetImage(GameData.Shared.Avatar); var dt = data.Dict("myself"); coins.text = _.Num2CnDigit(dt.Int("bankroll")); ts = data.Int("left_time"); setTime(); RoomName.text = name; var codeGo = inviteCode.transform.parent.gameObject; if (string.IsNullOrEmpty(code)) { codeGo.SetActive(false); } else { codeGo.SetActive(true); inviteCode.text = code; } if (disposable != null) { disposable.Dispose(); } disposable = Observable.Interval(TimeSpan.FromSeconds(1)).Where((_) => ts > 0).Subscribe((_) => { ts--; setTime(); if (ts <= 0) { disposable.Dispose(); } }).AddTo(this); }
public void Should_update_document_with_waitForSync() { var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "some other new string") .Int("bar", 54321) .Int("baz", 12345); var updateResult = db.Document .WaitForSync(true) .Update(documents[0].String("_id"), document); Assert.AreEqual(201, updateResult.StatusCode); Assert.IsTrue(updateResult.Success); Assert.IsTrue(updateResult.HasValue); Assert.AreEqual(updateResult.Value.String("_id"), documents[0].String("_id")); Assert.AreEqual(updateResult.Value.String("_key"), documents[0].String("_key")); Assert.AreNotEqual(updateResult.Value.String("_rev"), documents[0].String("_rev")); var getResult = db.Document .Get(updateResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_id"), updateResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_key"), updateResult.Value.String("_key")); Assert.AreEqual(getResult.Value.String("_rev"), updateResult.Value.String("_rev")); Assert.AreNotEqual(getResult.Value.String("foo"), documents[0].String("foo")); Assert.AreEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreNotEqual(getResult.Value.Int("bar"), documents[0].Int("bar")); Assert.AreEqual(getResult.Value.Int("bar"), document.Int("bar")); Assert.AreEqual(getResult.Value.Int("baz"), document.Int("baz")); }
public void Should_create_edge() { Database.ClearTestCollection(Database.TestEdgeCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "foo string value") .Int("bar", 12345); var createResult = db.Edge .Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document); Assert.AreEqual(202, createResult.StatusCode); Assert.IsTrue(createResult.Success); Assert.IsTrue(createResult.HasValue); Assert.IsTrue(createResult.Value.IsString("_id")); Assert.IsTrue(createResult.Value.IsString("_key")); Assert.IsTrue(createResult.Value.IsString("_rev")); var getResult = db.Edge .Get(createResult.Value.String("_id")); Assert.AreEqual(200, getResult.StatusCode); Assert.IsTrue(getResult.Success); Assert.IsTrue(getResult.HasValue); Assert.AreEqual(getResult.Value.String("_id"), createResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_key"), createResult.Value.String("_key")); Assert.AreEqual(getResult.Value.String("_rev"), createResult.Value.String("_rev")); Assert.IsTrue(getResult.Value.IsString("_from")); Assert.IsTrue(getResult.Value.IsString("_to")); Assert.AreEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.Int("bar"), document.Int("bar")); }
/// <summary> /// Determines the number of shards to create for the collection in cluster environment. Default value: 1. /// </summary> public ACollection NumberOfShards(int value) { _parameters.Int(ParameterName.NumberOfShards, value); return(this); }
private void byJson(Dictionary <string, object> json, bool gameStart = false) { var options = json.Dict("options"); var gamers = json.Dict("gamers"); Type.Value = string2GameType(json.String("type")); Coins = json.Int("coins"); Bankroll.Value = json.Int("bankroll"); BB = options.Int("limit"); OwnerName = json.Dict("owner").String("name"); Owner = options.String("ownerid") == GameData.Shared.Uid; BankrollMul = options.IL("bankroll_multiple"); Ante.Value = options.Int("ante"); PlayerCount.Value = options.Int("max_seats"); Rake = options.Float("rake_percent"); Duration = options.Int("time_limit"); NeedAudit = options.Int("need_audit") == 1; GPSLimit.Value = options.Int("gps_limit") > 0; IPLimit.Value = options.Int("ip_limit") == 1; Award27 = options.Int("award_27") == 1; BuryCard = options.Int("bury_card") == 1; GameCode.Value = options.String("code"); Straddle.Value = options.Int("straddle") == 1; SettingThinkTime = ThinkTime = options.Int("turn_countdown"); OffScore.Value = options.Int("off_score") == 1; LimitRule = options.Int("limit_rule") == 1; LeagueID = options.String("league_id"); AllowClubs = json.List("allowclubs"); NeedInsurance.Value = options.Int("need_insurance") == 1; DealerSeat.Value = json.Int("dealer_seat"); Pot.Value = json.Int("pot"); Pots.Value = json.DL("pots"); var startTs = json.Int("begin_time"); StartTime = _.DateTimeFromTimeStamp(startTs); // 游戏是否已开始 GameStarted.OnNext(startTs != 0); if (IsMatch()) { MatchData.Type = options.Int("sub_type"); MatchData.LimitLv = options.Int("limit_level"); MatchData.Rebuy = options.Int("rebuy_count"); MatchData.Addon = options.Int("add_on"); MatchData.IsHunter = options.Int("reward_ratio") > 0; BlindLv = json.Int("blind_lv"); MatchData.JoinFee = options.Int("join_fee"); MatchData.RebuyFee = options.Int("rebuy_fee"); MatchData.MatchRoomStatus.OnNext((MatchRoomStat)json.Int("match_room_status")); var lt = MatchData.MatchRoomStatus.Value == MatchRoomStat.Rest ? json.Int("half_break_countdown") : json.Int("blind_countdown"); LeftTime.OnNext(lt); MatchData.MTTType = options.Int("blind_type") == 0 ? MTTType.Normal : MTTType.Fast; } else { LeftTime.OnNext(json.Int("left_time")); } RoomName.Value = GameData.Shared.Type.Value == GameType.MTT ? json.String("match_name") : json.String("name"); if (GameData.Shared.Type.Value == GameType.MTT) { TableNumber.Value = json.Int("name"); // MTT的牌桌名称就是牌桌号 } else { TableNumber.Value = -1; } InGame = json.Bool("is_ingame"); MaxFiveRank.Value = json.Int("maxFiveRank"); _talkLimit.Value = json.Int("talk_limit") == 1; InsuranceState.Value = false; // 这个重置应该在pause设置之前 ShowAudit.Value = json.List("un_audit").Count > 0; CreateTime = _.DateTimeFromTimeStamp(json.Int("create_time")); Paused.OnNext(json.Int("is_pause")); // 删除公共牌重新添加 var cards = json.IL("shared_cards"); PublicCards.Clear(); foreach (int value in cards) { PublicCards.Add(value); } // 先设置公共牌,再高亮 HighlightIndex.Value = Card.ExtractHighlightCards(json.IL("maxFive"), MaxFiveRank.Value); // 逐个删除,才能触发Remove事件 foreach (var key in Players.Keys.ToList()) { Players.Remove(key); } foreach (KeyValuePair <string, object> entry in gamers) { var dict = entry.Value as Dictionary <string, object>; if (dict == null) { continue; } var index = Convert.ToInt32(entry.Key); var player = new Player(dict, index); // 大小盲、抓头、补盲 if (gameStart && player.PrChips.Value != 0) { player.ChipsChange = true; } Players[index] = player; } var mySeat = MySeat; if (mySeat != -1) { var player = Players[mySeat]; AuditCD.OnNext(player.AuditCD); GameData.Shared.Rank.Value = player.Rank.Value; } else { AuditCD.OnNext(0); GameData.Shared.Rank.Value = 0; } }
public void Should_get_edge_as_generic_object() { Database.ClearTestCollection(Database.TestEdgeCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "foo string value") .Int("bar", 12345); var createResult = db.Edge .Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document); var getResult = db.Edge .Get<Dummy>(createResult.Value.String("_id")); Assert.AreEqual(200, getResult.StatusCode); Assert.IsTrue(getResult.Success); Assert.IsTrue(getResult.HasValue); Assert.AreEqual(document.String("foo"), getResult.Value.Foo); Assert.AreEqual(document.Int("bar"), getResult.Value.Bar); Assert.AreEqual(0, getResult.Value.Baz); }
private void reload(Dictionary <string, object> ret) { totalNumber = ret.Int("total_hand"); HandSlider.maxValue = totalNumber; HandSlider.minValue = Mathf.Min(totalNumber, 1); HandSlider.value = currentNumber = ret.Int("cur_hand"); handId = ret.Int("handid"); Total.text = string.Format("/ {0}", totalNumber); Current.text = currentNumber.ToString(); var insuValue = ret.Dict("insurance").Int("score"); var win27Value = ret.Int("award_27"); SetPublicValue(insuValue, InsuranceGo); SetPublicValue(win27Value, Win27Go); var comCards = ret.Dict("community").IL("cards"); var list = ret.List("list"); for (int num = 0; num < 9; num++) { if (list.Count > num) // 复用的部分 { var dt = list[num] as Dictionary <string, object>; var tag = findTag(list, num); RecallUser user; if (num < users.Count) { user = users[num]; user.gameObject.SetActive(true); } else { var go = GameObject.Instantiate(RecallUserPrefab, Rect.transform); user = go.GetComponent <RecallUser>(); users.Add(user); } user.Show(dt); user.SetComCard(comCards, GameData.Shared.Type.Value); user.SetTag(tag); } else if (users.Count > num) // 超出的部分隐藏 { users[num].gameObject.SetActive(false); } } if (!string.IsNullOrEmpty(ret.String("favhand_id"))) { Collect.isOn = true; this.favhand_id = ret.String("favhand_id"); } else { Collect.isOn = false; } }
public void Should_create_edge_with_returnNew_parameter() { Database.ClearTestCollection(Database.TestEdgeCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .From(_documents[0].ID()) .To(_documents[1].ID()) .String("foo", "foo string value") .Int("bar", 12345); var createResult = db .Document .ReturnNew() .CreateEdge(Database.TestEdgeCollectionName, document); Assert.AreEqual(202, createResult.StatusCode); Assert.IsTrue(createResult.Success); Assert.IsTrue(createResult.HasValue); Assert.IsTrue(createResult.Value.IsString("_id")); Assert.IsTrue(createResult.Value.IsString("_key")); Assert.IsTrue(createResult.Value.IsString("_rev")); Assert.IsTrue(createResult.Value.Has("new")); Assert.AreEqual(createResult.Value.ID(), createResult.Value.String("new._id")); Assert.AreEqual(createResult.Value.Key(), createResult.Value.String("new._key")); Assert.AreEqual(createResult.Value.Rev(), createResult.Value.String("new._rev")); Assert.AreEqual(document.String("_from"), createResult.Value.String("new._from")); Assert.AreEqual(document.String("_to"), createResult.Value.String("new._to")); Assert.AreEqual(document.String("foo"), createResult.Value.String("new.foo")); Assert.AreEqual(document.Int("bar"), createResult.Value.Int("new.bar")); }
public void Should_replace_edge_with_waitForSync() { Database.ClearTestCollection(Database.TestEdgeCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "some string") .Int("bar", 12345); var createResult = db.Edge .Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document); var newDocument = new Dictionary<string, object>() .String("foo", "some other new string") .Int("baz", 54321); var replaceResult = db.Edge .WaitForSync(true) .Replace(createResult.Value.String("_id"), newDocument); Assert.AreEqual(201, replaceResult.StatusCode); Assert.IsTrue(replaceResult.Success); Assert.IsTrue(replaceResult.HasValue); Assert.AreEqual(replaceResult.Value.String("_id"), createResult.Value.String("_id")); Assert.AreEqual(replaceResult.Value.String("_key"), createResult.Value.String("_key")); Assert.AreNotEqual(replaceResult.Value.String("_rev"), createResult.Value.String("_rev")); var getResult = db.Edge .Get(replaceResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_id"), replaceResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_key"), replaceResult.Value.String("_key")); Assert.AreEqual(getResult.Value.String("_rev"), replaceResult.Value.String("_rev")); Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.String("foo"), newDocument.String("foo")); Assert.AreEqual(getResult.Value.Int("baz"), newDocument.Int("baz")); Assert.IsFalse(getResult.Value.Has("bar")); }
public void Should_update_edge_with_generic_object() { Database.ClearTestCollection(Database.TestEdgeCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "some string") .Int("bar", 12345); var createResult = db.Edge .Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document); var dummy = new Dummy(); dummy.Foo = "some other new string"; dummy.Bar = 54321; dummy.Baz = 12345; var updateResult = db.Edge .Update(createResult.Value.String("_id"), dummy); Assert.AreEqual(202, updateResult.StatusCode); Assert.IsTrue(updateResult.Success); Assert.IsTrue(updateResult.HasValue); Assert.AreEqual(updateResult.Value.String("_id"), createResult.Value.String("_id")); Assert.AreEqual(updateResult.Value.String("_key"), createResult.Value.String("_key")); Assert.AreNotEqual(updateResult.Value.String("_rev"), createResult.Value.String("_rev")); var getResult = db.Edge .Get(updateResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_id"), updateResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_key"), updateResult.Value.String("_key")); Assert.AreEqual(getResult.Value.String("_rev"), updateResult.Value.String("_rev")); Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.String("foo"), dummy.Foo); Assert.AreNotEqual(getResult.Value.Int("bar"), document.Int("bar")); Assert.AreEqual(getResult.Value.Int("bar"), dummy.Bar); Assert.AreEqual(getResult.Value.Int("baz"), dummy.Baz); }
public void Should_update_edge_with_ifMatch() { Database.ClearTestCollection(Database.TestEdgeCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "some string") .Int("bar", 12345); var createResult = db.Edge .Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document); var newDocument = new Dictionary<string, object>() .String("foo", "some other new string") .Int("bar", 54321) .Int("baz", 12345); var updateResult = db.Edge .IfMatch(createResult.Value.String("_rev")) .Update(createResult.Value.String("_id"), newDocument); Assert.AreEqual(202, updateResult.StatusCode); Assert.IsTrue(updateResult.Success); Assert.IsTrue(updateResult.HasValue); Assert.AreEqual(updateResult.Value.String("_id"), createResult.Value.String("_id")); Assert.AreEqual(updateResult.Value.String("_key"), createResult.Value.String("_key")); Assert.AreNotEqual(updateResult.Value.String("_rev"), createResult.Value.String("_rev")); var getResult = db.Edge .Get(updateResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_id"), updateResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_key"), updateResult.Value.String("_key")); Assert.AreEqual(getResult.Value.String("_rev"), updateResult.Value.String("_rev")); Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.String("foo"), newDocument.String("foo")); Assert.AreNotEqual(getResult.Value.Int("bar"), document.Int("bar")); Assert.AreEqual(getResult.Value.Int("bar"), newDocument.Int("bar")); // by default JSON integers are deserialized to long type Assert.IsTrue(getResult.Value.IsLong("baz")); }
public void Init(Dictionary <string, object> data, bool isBuyer = false) { GetComponent <DOPopup>().Show(); this.isBuyer = isBuyer; List <int> loseOuts = data.IL("lose_outs"); List <int> tieOuts = data.IL("tie_outs"); potValue = data.Int("pot"); cost = data.Int("cost"); scope = data.IL("scope"); mustBuy = data.Int("must_buy") == 2; isFlop = (data.Int("room_state") == 4); List <object> allinPlayers = data.List("outs_count"); int myRate = data.Int("win_rate"); insuranceOutsList[0].SetOuts(loseOuts, this); insuranceOutsList[1].SetOuts(tieOuts, this); //设置倒计时动画 var time = data.Int("time"); myCoroutine = Timer(time); StartCoroutine(myCoroutine); BuyTime.SetActive(true); ExitButton.gameObject.SetActive(!(mustBuy && isBuyer)); //区分观看者和购买者 BuyerButtons.SetActive(isBuyer); WatcherText.SetActive(!isBuyer); CASlider.interactable = isBuyer; SetOddsValueBySelectedCount(); Pot.text = potValue.ToString(); int maxPercent = -1; if (data.ContainsKey("win_rate")) { maxPercent = getMaxPercent(allinPlayers, myRate); } setupAllinPlayers(allinPlayers, maxPercent); setupPbCards(); addEvents(); CASlider.value = CASlider.minValue; // 还原最小值 //底部个人信息 var buyPlayer = GameData.Shared.FindPlayer(data.String("uid")); for (int i = 0; i < MyCards.Count; i++) { if (i < buyPlayer.Cards.Value.Count) { MyCards[i].parent.gameObject.SetActive(true); MyCards[i].GetComponent <Card>().Show(buyPlayer.Cards.Value[i]); } else { MyCards[i].parent.gameObject.SetActive(false); } } CardDesc.text = Card.GetCardDesc(data.Int("maxFiveRank")); // WinRate.text = myRate + "%"; // string color = myRate == maxPercent ? "#ff1744" : "#868d94"; // WinRate.transform.parent.gameObject.SetActive(maxPercent != -1); // WinRate.transform.parent.GetComponent<ProceduralImage>().color = _.HexColor(color); }
/// <summary> /// Determines whether the number of documents in the result set should be returned. Default value: false. /// </summary> public AQuery Ttl(int value) { _parameters.Int(ParameterName.TTL, value); return(this); }
/// <summary> /// Determines a numeric value that can be used to set a timeout for waiting on collection locks. Setting value to 0 will make ArangoDB not time out waiting for a lock. /// </summary> public ATransaction LockTimeout(int value) { _parameters.Int(ParameterName.LockTimeout, value); return(this); }
/// <summary> /// Determines minimum character length of words for fulltext index. Will default to a server-defined value if unspecified. It is thus recommended to set this value explicitly when creating the index. /// </summary> public AIndex MinLength(int value) { _parameters.Int(ParameterName.MinLength, value); return(this); }
public void Should_replace_document_with_ifMatch() { var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "some other new string") .Int("baz", 54321); var replaceResult = db.Document .IfMatch(documents[0].String("_rev")) .Replace(documents[0].String("_id"), document); Assert.AreEqual(202, replaceResult.StatusCode); Assert.IsTrue(replaceResult.Success); Assert.IsTrue(replaceResult.HasValue); Assert.AreEqual(replaceResult.Value.String("_id"), documents[0].String("_id")); Assert.AreEqual(replaceResult.Value.String("_key"), documents[0].String("_key")); Assert.AreNotEqual(replaceResult.Value.String("_rev"), documents[0].String("_rev")); var getResult = db.Document .Get(replaceResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_id"), replaceResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_key"), replaceResult.Value.String("_key")); Assert.AreEqual(getResult.Value.String("_rev"), replaceResult.Value.String("_rev")); Assert.AreNotEqual(getResult.Value.String("foo"), documents[0].String("foo")); Assert.AreEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.Int("baz"), document.Int("baz")); Assert.IsFalse(getResult.Value.Has("bar")); }
public void Should_replace_edge_with_ifMatch() { Database.ClearTestCollection(Database.TestEdgeCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "some string") .Int("bar", 12345); var createResult = db .Document .CreateEdge(Database.TestEdgeCollectionName, _documents[0].ID(), _documents[1].ID(), document); document.Merge(createResult.Value); var newDocument = new Dictionary<string, object>() .From(_documents[0].ID()) .To(_documents[1].ID()) .String("foo", "some other new string") .Int("baz", 54321); var replaceResult = db .Document .IfMatch(document.Rev()) .Replace(createResult.Value.ID(), newDocument); Assert.AreEqual(202, replaceResult.StatusCode); Assert.IsTrue(replaceResult.Success); Assert.IsTrue(replaceResult.HasValue); Assert.AreEqual(replaceResult.Value.ID(), document.ID()); Assert.AreEqual(replaceResult.Value.Key(), document.Key()); Assert.AreNotEqual(replaceResult.Value.Rev(), document.Rev()); var getResult = db .Document .Get(replaceResult.Value.ID()); Assert.AreEqual(getResult.Value.ID(), replaceResult.Value.ID()); Assert.AreEqual(getResult.Value.Key(), replaceResult.Value.Key()); Assert.AreEqual(getResult.Value.Rev(), replaceResult.Value.Rev()); Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.String("foo"), newDocument.String("foo")); Assert.AreEqual(getResult.Value.Int("baz"), newDocument.Int("baz")); Assert.IsFalse(getResult.Value.Has("bar")); }
public Player(Dictionary <string, object> json, int index) { Name = json.String("name"); Avatar = json.String("avatar"); Uid = json.String("uid"); // 用户记分牌 Bankroll.Value = json.Int("bankroll"); // 用户该轮上的筹码 PrChips.Value = json.Int("pr_chips"); // 用户该手上的总筹码 Chips = json.Int("chips"); Index = index; InGame = json.Bool("is_ingame"); AuditCD = json.Int("unaudit_countdown"); Coins = json.Int("coins"); Rank.Value = GameData.Shared.Type.Value == GameType.MTT ? json.Int("rank") : json.Int("match_rank"); readyState = json.Int("is_ready"); HeadValue.Value = json.Int("head_value"); if (json.Bool("is_allin")) { ActState.OnNext(ActionState.Allin); } else if (json.Int("tonic_blind") == 1) { ActState.OnNext(ActionState.TonicBlind); } else if (json.Int("straddle") == 1) { ActState.OnNext(ActionState.Straddle); } else { ActState.OnNext(json.String("last_act").ToActionEnum()); } if (GameData.Shared.IsMatch()) { AddonCount = json.Int("add_on"); RebuyCount = json.Int("rebuy_count"); } if (json.ContainsKey("win_rate")) { WinPercent.OnNext(json.Int("win_rate")); } ShowCard.Value = Convert.ToString(json.Int("showcard"), 2); var trust = json.Dict("trust"); SetTrust(trust); var cd = json.Int("turn_countdown"); if (cd > 0) { var dt = new RestoreData(); dt.seconds = cd; dt.data = new Dictionary <string, object> { { "cmds", json.Dict("cmds") } }; dt.BuyTimeCost = json.Int("show_moretime"); Countdown.OnNext(dt); } var cards = json.IL("cards"); Cards.OnNext(cards); var state = json.Int("gamer_state"); var ucd = json.Int("unseat_countdown"); SetState(state, ucd); }
public void Should_replace_edge_with_ifMatch_and_lastUpdatePolicy() { Database.ClearTestCollection(Database.TestEdgeCollectionName); var db = new ADatabase(Database.Alias); var document = new Dictionary<string, object>() .String("foo", "some string") .Int("bar", 12345); var createResult = db.Edge .Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document); document.Merge(createResult.Value); var newDocument = new Dictionary<string, object>() .String("foo", "some other new string") .Int("baz", 54321); var replaceResult = db.Edge .IfMatch("123456789", AUpdatePolicy.Last) .Replace(createResult.Value.String("_id"), newDocument); Assert.AreEqual(202, replaceResult.StatusCode); Assert.IsTrue(replaceResult.Success); Assert.IsTrue(replaceResult.HasValue); Assert.AreEqual(replaceResult.Value.String("_id"), document.String("_id")); Assert.AreEqual(replaceResult.Value.String("_key"), document.String("_key")); Assert.AreNotEqual(replaceResult.Value.String("_rev"), document.String("_rev")); var getResult = db.Document .Get(replaceResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_id"), replaceResult.Value.String("_id")); Assert.AreEqual(getResult.Value.String("_key"), replaceResult.Value.String("_key")); Assert.AreEqual(getResult.Value.String("_rev"), replaceResult.Value.String("_rev")); Assert.AreNotEqual(getResult.Value.String("foo"), document.String("foo")); Assert.AreEqual(getResult.Value.String("foo"), newDocument.String("foo")); Assert.AreEqual(getResult.Value.Int("baz"), newDocument.Int("baz")); Assert.IsFalse(getResult.Value.Has("bar")); }
public void Should_serialize_dictionary_to_strongly_typed_object() { var children = new List <Dictionary <string, object> >(); for (int i = 0; i < 5; i++) { var child = new Dictionary <string, object>() .String("Foo", "string " + i) .Int("Bar", i); children.Add(child); } var parent = new Dictionary <string, object>() .String("Foo", "parent string value") .Int("Bar", 11111); var primitiveDictionary = new Dictionary <string, string>(); primitiveDictionary.Add("aaa", "bbb"); var root = new Dictionary <string, object>() .String("Foo", "string value") .Int("Bar", 12345) .List("FooList", new List <string> { "one", "two", "three" }) .Document("Parent", parent) .List("Children", children) .Object("Dictionary", parent) .List("Dictionaries", children) .Object("PrimitiveDictionary", primitiveDictionary) .Array("PrimitiveArray", new[] { "one", "two", "three" }); var stronglyTypedObject = root.ToObject <Dummy>(); Assert.AreEqual(root.String("Foo"), stronglyTypedObject.Foo); Assert.AreEqual(root.Int("Bar"), stronglyTypedObject.Bar); Assert.AreEqual(root.String("Parent.Foo"), stronglyTypedObject.Parent.Foo); Assert.AreEqual(root.Int("Parent.Bar"), stronglyTypedObject.Parent.Bar); Assert.AreEqual(new List <string> { "one", "two", "three" }, stronglyTypedObject.FooList); for (int i = 0; i < 5; i++) { var obj = stronglyTypedObject.Children[i]; Assert.AreEqual("string " + i, obj.Foo); Assert.AreEqual(i, obj.Bar); } Assert.AreEqual(root.String("Dictionary.Foo"), stronglyTypedObject.Dictionary.String("Foo")); Assert.AreEqual(root.Int("Dictionary.Bar"), stronglyTypedObject.Dictionary.Int("Bar")); for (int i = 0; i < 5; i++) { var dict = stronglyTypedObject.Dictionaries[i]; Assert.AreEqual("string " + i, dict.String("Foo")); Assert.AreEqual(i, dict.Int("Bar")); } Assert.AreEqual(1, stronglyTypedObject.PrimitiveDictionary.Count); Assert.AreEqual(root.Object <Dictionary <string, string> >("PrimitiveDictionary")["aaa"], stronglyTypedObject.PrimitiveDictionary["aaa"]); Assert.AreEqual(root.Array <string>("PrimitiveArray"), stronglyTypedObject.PrimitiveArray); }