/// <summary> /// Get the card that the Ai passed in player will play /// </summary> /// <param name="hand">The current cards that are in play</param> /// <param name="player">The player that will be playing the card</param> /// <returns>The card played</returns> public async System.Threading.Tasks.Task<Card> GetAiCardPlay(Hand hand, Player player) { if (_feature.FeatureEnabled(AiSimulation.SimService)) { var sim = new BasicTrumpSimluation(); using (var client = new HttpClient()) { // translate inputs to the sim object var response = await client.PostAsJsonAsync("api/api/BasicTrumpSimulation", sim); if (response.IsSuccessStatusCode) { var card = response.Content.ReadAsAsync<Dto.AiSimulation.Card>(); // map to our card throw new NotImplementedException(); } else { // errored out yo throw new NotImplementedException(); } } } else { var aiSim = new AiSimulation(); return aiSim.PlayCard(hand, player); } }
public CardPlayer(CardGame game, bool setToAI, float difficultyModifier = 0) { isAI = setToAI; if (difficultyModifier < 0) { aiDifficultyScale = 0; } else if (difficultyModifier > 1) { aiDifficultyScale = 1; } else { aiDifficultyScale = difficultyModifier; } cardGame = game; playerName = "Player"; maxCardsInHand = 5; averageCardValue = 4; cardGrowthValue = 2; playerHealth = 100; randomCardValueWeight = new int[] {5, 10, 20, 30, 20, 10, 5}; playerHand = new Hand (); randomCardValueTotalWeight = 0; foreach (int value in randomCardValueWeight) { randomCardValueTotalWeight += value; } cardSumSequenceList = new List<CardSumSequence> (); }
public void AddTest() { Hand a = new Hand(); Card c = Card.Joker; a.Add(c); Assert.AreEqual(a[0], c); }
public override void TestGesture(Hand hand) { if (TestPosture(hand)) { GestureRecognized(); } }
public AceExorcistGame() { //Create Deck and Hand for Exorcist, and draw 5 cards from Deck to Hand ExorcistLibrary = new Deck(IsExorcist); ExorcistHand = new Hand(); for (int i = 1; i < 6; i++) { ExorcistHand.addCard( ExorcistLibrary.TakeCard() ); } //Create Deck and Hand for Exorcist, and draw 5 cards from Deck to Hand IsExorcist = false; SummonerLibrary = new Deck(IsExorcist); for (int i = 1; i < 6; i++) { SummonerHand.addCard(SummonerLibrary.TakeCard()); } //Create Summon Zone SummonZone = new Hand(); //Create Discards (as a Hand - but not in this implementation) }
void HandleMovement(Hand currentFrameHand) { horizontalMove = 0; verticalMove = 0; horizontalLook = 0; if(currentFrameHand.IsValid) { horizontalMove = hMoveScale * currentFrameHand.PalmNormal.Roll / Mathf.PI ; verticalMove = vMoveScale * currentFrameHand.Direction.Pitch / Mathf.PI; horizontalLook = hLookScale * currentFrameHand.Direction.Yaw / Mathf.PI; // debug visualization //Debug.DrawLine(transform.position, transform.position + new Vector3(currentFrameHand.PalmNormal.Roll , 0, 0) * 2.150f, Color.green, 0, false); //Debug.DrawLine(transform.position, transform.position + new Vector3(0 , currentFrameHand.Direction.Pitch, 0) * 2.150f, Color.blue, 0, false); //Debug.DrawLine(transform.position, transform.position + new Vector3(0 , 0, currentFrameHand.Direction.Yaw) * 2.150f, Color.red, 0, false); } if(Mathf.Abs(horizontalMove) < 5) { acrobaticsScript.RotateToInitialRotation(); } else { playerScript.HandleControls(-horizontalMove, -verticalMove); } //Debug.Log(horizontalMove); }
void Start() { itemCollection = transform.FindChild("Items").gameObject; leftHand = GameObject.Find("Left Hand").GetComponent<Hand>(); rightHand = GameObject.Find("Right Hand").GetComponent<Hand>(); hands = new Hand[] { leftHand, rightHand }; }
//Test the initial posture of the hand to start the gesture protected override void TestInitialGesture(Hand hand) { InitialPosition = hand.PalmPosition.x; PreviousHand = hand; ListeGesture[0].TestGesture(hand); //ReceiveBeginningRightMoveEvent(); }
/// <summary> /// The entry point of the program. /// </summary> private static void Main() { try { IHandEvaluator handEvaluator = new HandEvaluator(); ICard[] cards = new ICard[] { new Card(CardRank.Queen, CardSuit.Hearts), new Card(CardRank.Queen, CardSuit.Spades), new Card(CardRank.Ten, CardSuit.Hearts), new Card(CardRank.Queen, CardSuit.Diamonds), new Card(CardRank.Queen, CardSuit.Clubs) }; IHand hand = new Hand(cards); Console.WriteLine(handEvaluator.GetCategory(hand) == HandCategory.FourOfAKind); IHand handFromString = new Hand("7♠ 5♣ 4♦ 3♦ 2♣"); Console.WriteLine(handFromString); } catch (ArgumentException aex) { Console.WriteLine(aex.Message); } }
public void SetLeapHand(Hand hand) { hand_ = hand; for (int i = 0; i < fingers.Length; ++i) { if (fingers[i] != null) fingers[i].SetLeapHand(hand_); } }
public void twoHandsWithTheSameCardsShouldBeEqual() { var Hand = new Hand(asCardArray("A-S", "K-H", "Q-D", "J-C", "10-S")); var OtherHand = new Hand(asCardArray("A-S", "K-H", "Q-D", "J-C", "10-S")); Assert.IsTrue(Hand.Equals(OtherHand)); }
// Update is called once per frame void Update() { frame = lp.CurrentFrame; if (frame.Hands.Count > 0) { if (frame.Hands.Leftmost.IsLeft) { righty = frame.Hands.Leftmost; rfingers = right.fingers; } } if (right.isActiveAndEnabled) { if (Vector3.Distance (right.GetPalmPosition (), rfingers [0].GetTipPosition ()) > trigger && Vector3.Distance (right.GetPalmPosition (), rfingers [1].GetTipPosition ()) > trigger && Vector3.Distance (right.GetPalmPosition (), rfingers [2].GetTipPosition ()) < trigger && Vector3.Distance (right.GetPalmPosition (), rfingers [3].GetTipPosition ()) < trigger && Vector3.Distance (right.GetPalmPosition (), rfingers [4].GetTipPosition ()) < trigger ) { Debug.Log ("rockgod!!"); rockgod = true; } else { rockgod = false; } if (rockgod) { line.enabled = true; Ray ray = new Ray (rfingers [1].GetTipPosition (), rfingers[1].GetBoneDirection(2)); // Ray ray1 = new Ray (rfingers [4].GetTipPosition (), rfingers [4].GetBoneDirection ()); line.SetPosition (0, ray.origin); line.SetPosition (1, ray.GetPoint (100)); } else { line.enabled = false; } } }
public void twoHandsThatAreNotEqualShouldHaveDifferentHashCodes() { var Hand = new Hand(asCardArray("A-S", "K-H", "Q-D", "J-C", "10-S")); var OtherHand = new Hand(asCardArray("Q-D", "10-C", "K-H", "A-S", "J-C")); Assert.AreNotEqual(Hand.GetHashCode(), OtherHand.GetHashCode()); }
public void twoHandsWithDifferentCardsShouldNotBeEqual() { var Hand = new Hand(asCardArray("J-H", "A-S", "5-C", "7-D", "3-C")); var OtherHand = new Hand(asCardArray("A-C", "K-D", "4-D", "3-S", "6-H")); Assert.IsFalse(Hand.Equals(OtherHand)); }
public WarViewModel(HandResult result) { PlayerOneHand = result.PlayerOneHand; PlayerTwoHand = result.PlayerTwoHand; RecentResults = result; }
private static void DisplayHand(Hand hand) { foreach (var card in hand.Cards) { Console.WriteLine(card.Name + ", " + card.ShortName); } }
[TestMethod] // ♣ public void ToString_StringEmptyHand() // ♦ { // ♥ IHand hand = new Hand(new List<ICard>()); // ♠ string actual = hand.ToString(); Assert.AreEqual(String.Empty, actual, "Tostring() method of Hand not implemented currenctly."); }
void checkGrabbed(Hand hand) { if (hand.GrabStrength > MinGrabStrength) Globals.SlowMotion = true; if (hand.GrabStrength <= MinGrabStrength) Globals.SlowMotion = false; }
protected override void UpdateTracker() { previousPosition = Position; previousOrientation = Orientation; previousGrabbingStrength = currentGrabbingStrength; //get the rightmost hand in the frame if (handController.GetAllGraphicsHands().Length != 0) { handModel = handController.GetAllGraphicsHands()[0]; handModel.transform.GetComponentInChildren<SkinnedMeshRenderer>().enabled = visibleHand; hand = handModel.GetLeapHand(); currentGrabbingStrength = lowPassFilter(hand.GrabStrength, previousGrabbingStrength); Position = lowPassFilter(handModel.GetPalmPosition(), previousPosition); Orientation = lowPassFilter(handModel.GetPalmDirection(), previousOrientation); } //mask/display the graphical hand on key down if (Input.GetKeyDown(visibleHandKey)) { var smr = handModel.transform.GetComponentInChildren<SkinnedMeshRenderer>(); visibleHand = !visibleHand; } Translation = Position - previousPosition; Rotation = previousOrientation - Orientation; }
public Hand DetermineStrongestHand(Hand handOne, Hand handTwo) { Hand bestHand = null; var handSize = handOne.GetCards().Count; handOne.ArrangeCardsHighToLow(); handTwo.ArrangeCardsHighToLow(); var kickerBreaker = new GroupsOfCardsOfSameValueTieBreaker(handOne, handTwo); bestHand = kickerBreaker.DetermineStrongestHand(1); for (var i = 0; i < handSize; i++) { if (handOne.GetCards()[i].GetCardValue() > handTwo.GetCards()[i].GetCardValue()) { bestHand = handOne; break; } if (handTwo.GetCards()[i].GetCardValue() > handOne.GetCards()[i].GetCardValue()) { bestHand = handTwo; break; } } return bestHand; }
public void SwitchGesture(string nextGesture, Hand side) { switch (side) { case Hand.left: foreach (var gesture in sGestures_L) { if (gesture == nextGesture) animator.SetBool("l_" + gesture, true); else animator.SetBool("l_" + gesture, false); actualGestureL = nextGesture; } break; case Hand.right: foreach (var gesture in sGestures_R) { if (gesture == nextGesture) animator.SetBool("r_" + gesture, true); else animator.SetBool("r_" + gesture, false); actualGestureR = nextGesture; } break; default: break; } }
void Update() { Controller controller = new Controller(); Frame frame = controller.Frame(); HandList hands = frame.Hands; hand = hands[0]; otherHand = hands[1]; }
public Card MakePlay(Card Down, Hand Hand) { List<Card> V = new List<Card>(); foreach (Card Card in Hand) { if (_Function.Invoke(Down, Card)) V.Add(Card); } int M = Int32.MaxValue; Card Choice = null; foreach (Card Card in V) { int N = 0; foreach (Card DownCard in _ImaginaryDeck) { if (_Function.Invoke(DownCard, Card)) N++; } if (N < M) { M = N; Choice = Card; } } return Choice; }
void checkGrabbed(Hand hand) { if (hand.GrabStrength > OnGrabStrength) Globals.SetSlowMotionTrue(); if (hand.GrabStrength <= OffGrabStrength) Globals.SetSlowMotionFalse(); }
// Use this for initialization void Start () { //for now, has the same amount as a normal deck? cardAmount = 30; cardsRemaining=cardAmount; maxHandValue = 6; //this is also specified in AceExorcistGames.cs??? //deck = new Deck(); - moved this into AceExorcistGames.cs //create references to the player's Hand component and the enemy's playerH = GameObject.Find("Player_Hand").GetComponent<Hand>(); enemyH = GameObject.Find("Enemy_Hand").GetComponent<Hand>(); //Tests to see if card deck really works Debug.Log("Amount of cards: " + deck.Cards.Count); //shuffles deck deck.shuffleDeck(); //Shows each card for that deck Debug.Log("Cards on this deck"); for(int i =0;i< deck.Cards.Count;i++) { Debug.Log(deck.Cards[i].cardValue + " of "+ deck.Cards[i].Suit); } }
public HandCoords NormalizedCoords(Hand h, float HorizontalAngle, float VerticalAngle) { HandCoords coords = AngleCoords(h); coords.horizontal = (coords.horizontal - (90 - HorizontalAngle/2))/HorizontalAngle; coords.vertical = (coords.vertical - (90 - VerticalAngle / 2)) / VerticalAngle; return coords; }
//public City CurrentCity; //public int cityID; public void Start() { //roleCard = new GameObject("roleCard").AddComponent<_roleCard>(); print("Start of Player"); hand = new GameObject("hand").AddComponent<Hand>(); }
private bool checkStabiliseGesture(Hand leftHand, Hand rightHand) { float leftHandHeight = leftHand.PalmPosition.y; float rightHandHeight = rightHand.PalmPosition.y; float averageHandHeight = (leftHandHeight + rightHandHeight) / 2; if(!stabiliseTopHit){ if(averageHandHeight > 175){ stabiliseTopHit = true; startTime = Time.time; return false; } }else{ if(averageHandHeight <= 120){ float timeDiff = Time.time - startTime; if(timeDiff < 0.9){ Debug.Log("Time Diff: " + timeDiff); stabiliseTopHit = false; return true; }else{ stabiliseTopHit = false; Debug.Log ("Out of Time"); } } } return false; }
public void TestIsValidHand_WithNoCards() { Hand currentHand = new Hand(new List<ICard>()); PokerHandsChecker checker = new PokerHandsChecker(); bool isValidHand = checker.IsValidHand(currentHand); Assert.AreEqual(false, isValidHand); }
public static int EvaluateCards(Hand hand) { int[] cards = new int[hand.Count]; for (int i = 0; i < hand.Count; i++) cards[i] = hand.ElementAt(i).Number; return EvaluateCards(cards); }
public void StartHoldTimer(Hand hand) { StartCoroutine(_HoldTimer(hand)); }
private void ShowPlayableHands() { // clear the screen canvas.Children.Clear(); // display a grid for non-paired hands without an ace. One column for each possible dealer upcard AddColorBox(Colors.White, "", 0, 0); int x = 1, y = 0; for (int upcardRank = 2; upcardRank < 12; upcardRank++) { string upcardRankName = (upcardRank == 11) ? "A" : upcardRank.ToString(); AddColorBox(Colors.White, upcardRankName, x, 0); y = 1; var best = solutionByUpcard[upcardRankName]; for (int hardTotal = 20; hardTotal > 4; hardTotal--) { // add a white box with the total AddColorBox(Colors.White, hardTotal.ToString(), 0, y); var deck = new MultiDeck(TestConditions.NumDecks); // build dealer hand Hand dealerHand = new Hand(); dealerHand.AddCard(new Card(upcardRankName, "S")); // build player hand Hand playerHand = new Hand(); // divide by 2 if it's even, else add one and divide by two int firstCardRank = ((hardTotal % 2) != 0) ? (hardTotal + 1) / 2 : hardTotal / 2; int secondCardRank = hardTotal - firstCardRank; playerHand.AddCard(new Card(firstCardRank, "D")); playerHand.AddCard(new Card(secondCardRank, "S")); Debug.Assert(playerHand.HandValue() == hardTotal); // get strategy and display best.StateData.PlayerHands.Clear(); best.StateData.PlayerHands.Add(playerHand); best.StateData.VotesForDoubleDown = 0; best.StateData.VotesForHit = 0; best.StateData.VotesForStand = 0; best.StateData.VotesForSplit = 0; best.Evaluate(); // get the decision //Solution.DebugDisplayStrategy(best, "Final"); var action = Solution.GetAction(best.StateData); // Now draw the box switch (action) { case ActionToTake.Hit: AddColorBox(Colors.Green, "H", x, y); break; case ActionToTake.Stand: AddColorBox(Colors.Red, "S", x, y); break; case ActionToTake.Double: AddColorBox(Colors.Yellow, "D", x, y); break; } y++; } x++; } // and another for hands with an ace // display a grid for hands without an ace. One column for each possible dealer upcard const int leftColumnForAces = 12; AddColorBox(Colors.White, "", leftColumnForAces, 0); x = leftColumnForAces + 1; for (int upcardRank = 2; upcardRank < 12; upcardRank++) { string upcardRankName = (upcardRank == 11) ? "A" : upcardRank.ToString(); AddColorBox(Colors.White, upcardRankName, x, 0); y = 1; var best = solutionByUpcard[upcardRankName]; // we don't start with Ace, because that would be AA, which is handled in the pair zone // we also don't start with 10, since that's blackjack. So 9 is our starting point for (int otherCard = 9; otherCard > 1; otherCard--) { string otherCardRank = (otherCard == 11) ? "A" : otherCard.ToString(); // add a white box with the player hand: "A-x" AddColorBox(Colors.White, "A-" + otherCardRank, leftColumnForAces, y); var deck = new MultiDeck(TestConditions.NumDecks); // build dealer hand Hand dealerHand = new Hand(); dealerHand.AddCard(new Card(upcardRankName, "S")); // build player hand Hand playerHand = new Hand(); // first card is an ace, second card is looped over playerHand.AddCard(new Card("AH")); // ace of hearts playerHand.AddCard(new Card(otherCardRank, "S")); // get strategy and display best.StateData.PlayerHands.Clear(); best.StateData.PlayerHands.Add(playerHand); best.StateData.VotesForDoubleDown = 0; best.StateData.VotesForHit = 0; best.StateData.VotesForStand = 0; best.Evaluate(); // get the decision //Solution.DebugDisplayStrategy(best, "Final"); var action = Solution.GetAction(best.StateData); // Now draw the box switch (action) { case ActionToTake.Hit: AddColorBox(Colors.Green, "H", x, y); break; case ActionToTake.Stand: AddColorBox(Colors.Red, "S", x, y); break; case ActionToTake.Double: AddColorBox(Colors.Yellow, "D", x, y); break; } y++; } x++; } // finally, a grid for pairs int startY = y + 1; AddColorBox(Colors.White, "", leftColumnForAces, 0); x = leftColumnForAces + 1; for (int upcardRank = 2; upcardRank < 12; upcardRank++) { string upcardRankName = (upcardRank == 11) ? "A" : upcardRank.ToString(); AddColorBox(Colors.White, upcardRankName, x, 0); y = startY; var best = solutionByUpcard[upcardRankName]; for (int pairedCard = 11; pairedCard > 1; pairedCard--) { string pairedCardRank = (pairedCard == 11) ? "A" : pairedCard.ToString(); // add a white box with the player hand: "x-x" AddColorBox(Colors.White, pairedCardRank + "-" + pairedCardRank, leftColumnForAces, y); var deck = new MultiDeck(TestConditions.NumDecks); deck.RemoveCard(pairedCardRank, "H"); deck.RemoveCard(pairedCardRank, "S"); deck.RemoveCard(upcardRankName, "D"); // build dealer hand Hand dealerHand = new Hand(); dealerHand.AddCard(new Card(upcardRankName, "D")); // build player hand Hand playerHand = new Hand(); playerHand.AddCard(new Card(pairedCardRank, "H")); // X of hearts playerHand.AddCard(new Card(pairedCardRank, "S")); // X of spades // get strategy and display best.StateData.PlayerHands.Clear(); best.StateData.PlayerHands.Add(playerHand); best.StateData.VotesForDoubleDown = 0; best.StateData.VotesForHit = 0; best.StateData.VotesForStand = 0; best.Evaluate(); // get the decision //Solution.DebugDisplayStrategy(best, "Final"); var action = Solution.GetAction(best.StateData); // Now draw the box switch (action) { case ActionToTake.Hit: AddColorBox(Colors.Green, "H", x, y); break; case ActionToTake.Stand: AddColorBox(Colors.Red, "S", x, y); break; case ActionToTake.Double: AddColorBox(Colors.Yellow, "D", x, y); break; case ActionToTake.Split: AddColorBox(Colors.LightBlue, "P", x, y); break; } y++; } x++; } }
public Finger(int digit, Hand hand) { this.digit = digit; this.hand = hand; }
private void addAllValidHandsToDictionary(Dictionary <PockerHands, IHand> allPockerHands) { IHand straightFlushHand = new Hand(new List <ICard>() { new Card(CardFace.Five, CardSuit.Spades), new Card(CardFace.Six, CardSuit.Spades), new Card(CardFace.Seven, CardSuit.Spades), new Card(CardFace.Eight, CardSuit.Spades), new Card(CardFace.Nine, CardSuit.Spades) }); allPockerHands.Add(PockerHands.StraightFlush, straightFlushHand); IHand fourOfAKindHand = new Hand(new List <ICard>() { new Card(CardFace.Ace, CardSuit.Spades), new Card(CardFace.Ace, CardSuit.Hearts), new Card(CardFace.Ace, CardSuit.Clubs), new Card(CardFace.Ace, CardSuit.Diamonds), new Card(CardFace.Nine, CardSuit.Spades) }); allPockerHands.Add(PockerHands.FourOfAKind, fourOfAKindHand); IHand fullHouseHand = new Hand(new List <ICard>() { new Card(CardFace.Ace, CardSuit.Spades), new Card(CardFace.Ace, CardSuit.Hearts), new Card(CardFace.Ace, CardSuit.Clubs), new Card(CardFace.Nine, CardSuit.Diamonds), new Card(CardFace.Nine, CardSuit.Spades) }); allPockerHands.Add(PockerHands.FullHouse, fullHouseHand); IHand flushHand = new Hand(new List <ICard>() { new Card(CardFace.Five, CardSuit.Spades), new Card(CardFace.Three, CardSuit.Spades), new Card(CardFace.Ace, CardSuit.Spades), new Card(CardFace.Seven, CardSuit.Spades), new Card(CardFace.Jack, CardSuit.Spades) }); allPockerHands.Add(PockerHands.Flush, flushHand); IHand straightHand = new Hand(new List <ICard>() { new Card(CardFace.Seven, CardSuit.Spades), new Card(CardFace.Eight, CardSuit.Hearts), new Card(CardFace.Nine, CardSuit.Clubs), new Card(CardFace.Ten, CardSuit.Diamonds), new Card(CardFace.Jack, CardSuit.Spades) }); allPockerHands.Add(PockerHands.Straight, straightHand); IHand threeOfAKindHand = new Hand(new List <ICard>() { new Card(CardFace.Seven, CardSuit.Spades), new Card(CardFace.Seven, CardSuit.Hearts), new Card(CardFace.Seven, CardSuit.Clubs), new Card(CardFace.Ten, CardSuit.Diamonds), new Card(CardFace.Jack, CardSuit.Spades) }); allPockerHands.Add(PockerHands.ThreeOfAKind, threeOfAKindHand); IHand twoPairHand = new Hand(new List <ICard>() { new Card(CardFace.Seven, CardSuit.Spades), new Card(CardFace.Seven, CardSuit.Hearts), new Card(CardFace.Ten, CardSuit.Clubs), new Card(CardFace.Ten, CardSuit.Diamonds), new Card(CardFace.Jack, CardSuit.Spades) }); allPockerHands.Add(PockerHands.TwoPair, twoPairHand); IHand onePairHand = new Hand(new List <ICard>() { new Card(CardFace.Seven, CardSuit.Spades), new Card(CardFace.Seven, CardSuit.Hearts), new Card(CardFace.Ten, CardSuit.Clubs), new Card(CardFace.Two, CardSuit.Diamonds), new Card(CardFace.Jack, CardSuit.Spades) }); allPockerHands.Add(PockerHands.OnePair, onePairHand); IHand highCardHand = new Hand(new List <ICard>() { new Card(CardFace.Ace, CardSuit.Spades), new Card(CardFace.Seven, CardSuit.Hearts), new Card(CardFace.Ten, CardSuit.Clubs), new Card(CardFace.Two, CardSuit.Diamonds), new Card(CardFace.Jack, CardSuit.Spades) }); allPockerHands.Add(PockerHands.HighCard, highCardHand); }
/// <summary> /// 描画時に呼び出される。 /// 対局盤面を描画する。 /// </summary> public void OnDraw(Graphics g_) { graphics = g_; /// 以降、このクラスのDrawSprite(),DrawString()は正常にaffine変換されて描画されるものとする。 // ここではDrawSprite()とDrawString()だけで描画を完結させてあるので複数Viewへの対応は(描画だけなら)容易。 var app = TheApp.app; var config = app.config; var vm = ViewModel; // 対局を監視しているLocalGameServer var gameServer = vm.ViewModel.gameServer; // 描画する局面 var pos = gameServer.Position; // MainDialogViewModel // 掴んでいる駒などのViewの状態 var state = vm.viewState; var picked_from = state.picked_from; // 持ち上げている駒のスプライトと座標(最後に描画するために積んでおく) Sprite picked_sprite = null; Point picked_sprite_location = new Point(0, 0); // 盤面を反転させて描画するかどうか var reverse = gameServer.BoardReverse; // -- 盤面の描画 { // 座標系はストレートに指定しておけばaffine変換されて適切に描画される。 DrawSprite(new Point(0, 0), SPRITE.Board()); } // -- 駒の描画 { // -- 盤上の駒 // 最終手(初期盤面などでは存在せず、lastMove == Move.NONEであることに注意) var lastMove = pos.State().lastMove; // 最終手の移動元の升 var lastMoveFrom = (lastMove != ShogiCore.Move.NONE && !lastMove.IsDrop()) ? lastMove.From() : Square.NB; // 最終手の移動先の升 var lastMoveTo = (lastMove != ShogiCore.Move.NONE) ? lastMove.To() : Square.NB; for (Square sq = Square.ZERO; sq < Square.NB; ++sq) { var pc = pos.PieceOn(sq); var dest = PieceLocation((SquareHand)sq); // ダイアログが出ている時や、駒を掴んでいるときは最終手のエフェクトがあると紛らわしいので消す。 if (state.state == GameScreenViewStateEnum.Normal) { // これが最終手の移動元の升であるなら、エフェクトを描画する。 if (sq == lastMoveFrom) { var piece_to = pos.PieceOn(lastMoveTo); DrawSprite(dest, SPRITE.PieceMove(PieceMoveEffect.From, piece_to)); } // これが最終手の移動先の升であるなら、エフェクトを描画する。 if (sq == lastMoveTo) { DrawSprite(dest, SPRITE.PieceMove(PieceMoveEffect.To)); } } var sprite = SPRITE.Piece(reverse ? pc.Inverse() : pc); // いま持ち上げている駒であるなら、少し持ち上げている感じで描画する if (picked_from != SquareHand.NB) { // ただし、一番手前に描画したいので、この駒は一番最後に描画する。 // (なので今回の描画はskipする) if (sq == (Square)picked_from) { // 移動元の升に適用されるエフェクトを描画する。 DrawSprite(dest, SPRITE.PieceMove(PieceMoveEffect.PickedFrom)); picked_sprite_location = dest + new Size(-5, -20); picked_sprite = sprite; continue; } else { // 駒を持ち上げてはいる時の移動先の候補の升のエフェクト // 移動先の候補の升か? var movable = vm.viewState.picked_piece_legalmovesto.IsSet(sq); if (movable && config.PickedMoveToColorType >= 4) // 移動先の候補の升を明るく { var picked_pc = pos.PieceOn(picked_from); DrawSprite(dest, SPRITE.PieceMove(PieceMoveEffect.PickedTo, picked_pc)); } else if (!movable && config.PickedMoveToColorType < 4) { // 移動先の候補以外の升を暗く DrawSprite(dest, SPRITE.PieceMove(PieceMoveEffect.PickedTo)); } } } // 盤面反転モードなら、駒を先後入れ替えて描画する。 DrawSprite(dest, sprite); } // -- 手駒の描画 foreach (var c in All.Colors()) { Hand h = pos.Hand(c); // 枚数によって位置が自動調整されるの、わりと見づらいので嫌。 // 駒種によって位置固定で良いと思う。 //同種の駒が3枚以上になったときに、その駒は1枚だけを表示して、 //数字を右肩表示しようと考えていたのですが、例えば、金が2枚、 //歩が3枚あるときに、歩だけが数字表示になるのはどうもおかしい気が //するのです。2枚以上は全部数字表示のほうが良いだろう。 foreach (var pc in hand_piece_list) { int count = h.Count(pc); if (count != 0) { // この駒の描画されるべき位置を求めるためにSquareHand型に変換する。 var piece = Util.ToSquareHand(c, pc); var dest = PieceLocation(piece); // 物理画面で後手側の駒台への描画であるか(駒を180度回転さて描画しないといけない) var is_white_in_display = (c == SColor.WHITE) ^ reverse; var sprite = SPRITE.Piece(is_white_in_display ? pc.Inverse() : pc); // この駒を掴んでいるならすごしずれたところに描画する。 // ただし、掴んでいるので描画を一番最後に回す if (picked_from == piece) { // 移動元の升に適用されるエフェクトを描画する。 DrawSprite(dest, SPRITE.PieceMove(PieceMoveEffect.PickedFrom)); picked_sprite_location = dest + new Size(-5, -20); picked_sprite = sprite; } else { // 駒の描画 DrawSprite(dest, sprite); } // 数字の描画(枚数が2枚以上のとき) if (count >= 2) { DrawSprite(dest + hand_number_offset, SPRITE.HandNumber(count)); } } } } // -- 駒箱の駒の描画(盤面編集時のみ) { // 駒箱の駒 var h = pos.Hand(SColor.NB); foreach (var pt in piece_box_list) { int count = pos.PieceBoxCount(pt); if (count > 0) { var dest = PieceLocation((int)(pt - 1) + SquareHand.PieceBox); DrawSprite(dest, SPRITE.Piece(pt)); // 数字の描画(枚数が2枚以上のとき) if (count >= 2) { DrawSprite(dest + hand_number_offset2, SPRITE.HandNumber(count)); } } } } } // -- 盤の段・筋を表す数字の表示 { var version = config.BoardNumberImageVersion; DrawSprite(board_number_pos[0], SPRITE.BoardNumberFile(reverse)); DrawSprite(board_number_pos[1], SPRITE.BoardNumberRank(reverse)); } // -- 対局者氏名 { switch (config.KomadaiImageVersion) { // 通常状態の駒台表示 case 1: DrawString(name_plate_name[0], gameServer.ShortDisplayName(reverse ? SColor.WHITE : SColor.BLACK), 28); DrawString(name_plate_name[1], gameServer.ShortDisplayName(reverse ? SColor.BLACK : SColor.WHITE), 28); break; // 細長い状態の駒台表示 case 2: DrawSprite(turn_slim_pos, SPRITE.NamePlateSlim(pos.sideToMove, reverse)); DrawString(name_plate_slim_name[0], gameServer.ShortDisplayName(reverse ? SColor.WHITE : SColor.BLACK), 28, new DrawStringOption(Brushes.White, 2)); DrawString(name_plate_slim_name[1], gameServer.ShortDisplayName(reverse ? SColor.BLACK : SColor.WHITE), 28, new DrawStringOption(Brushes.White, 0)); break; } } // -- 持ち時間等 { switch (config.KomadaiImageVersion) { // 通常状態の駒台表示 case 1: // 対局時間設定 DrawString(time_setting_pos[0], gameServer.TimeSettingString(reverse ? SColor.WHITE : SColor.BLACK), 18); DrawString(time_setting_pos[1], gameServer.TimeSettingString(reverse ? SColor.BLACK : SColor.WHITE), 18); // 残り時間 DrawString(time_setting_pos2[0], gameServer.RestTimeString(reverse ? SColor.WHITE : SColor.BLACK), 28, new DrawStringOption(Brushes.Black, 1)); DrawString(time_setting_pos2[1], gameServer.RestTimeString(reverse ? SColor.BLACK : SColor.WHITE), 28, new DrawStringOption(Brushes.Black, 1)); break; // 細長い状態の駒台表示 case 2: // 対局時間設定(表示する場所がなさげ) //DrawString(time_setting_slim_pos[0], gameServer.TimeSettingString(reverse ? SColor.WHITE : SColor.BLACK), 18 , new DrawStringOption(Brushes.Black, 2)); //DrawString(time_setting_slim_pos[1], gameServer.TimeSettingString(reverse ? SColor.BLACK : SColor.WHITE), 18 , new DrawStringOption(Brushes.Black, 0)); // 残り時間 DrawString(time_setting_slim_pos2[0], gameServer.RestTimeString(reverse ? SColor.WHITE : SColor.BLACK), 24, new DrawStringOption(Brushes.Black, 1)); DrawString(time_setting_slim_pos2[1], gameServer.RestTimeString(reverse ? SColor.BLACK : SColor.WHITE), 24, new DrawStringOption(Brushes.Black, 1)); break; } } // -- 手番の表示 { // 手番側が先手なら0、後手なら1。ただし、盤面反転しているなら、その逆。 int side = pos.sideToMove == SColor.BLACK ? 0 : 1; side = reverse ? (side ^ 1) : side; switch (config.KomadaiImageVersion) { case 1: DrawSprite(turn_normal_pos[side], SPRITE.TurnNormal()); break; case 2: DrawSprite(turn_slim_pos, SPRITE.TurnSlim(pos.sideToMove, reverse)); break; } } // -- 持ち上げている駒があるなら、一番最後に描画する。 { if (picked_sprite != null) { DrawSprite(picked_sprite_location, picked_sprite); } } // -- 成り、不成の選択ダイアログを出している最中であるなら if (state.state == GameScreenViewStateEnum.PromoteDialog) { DrawSprite(state.promote_dialog_location, SPRITE.PromoteDialog(state.promote_dialog_selection, state.moved_piece_type)); } // -- エンジン初期化中のダイアログ if (vm.ViewModel.gameServer.EngineInitializing) { DrawSprite(engine_init_pos, SPRITE.EngineInit()); } // 描画が完了したのでDirtyフラグを戻しておく。 vm.dirty = false; }
protected void OnPreCullHandTransforms(Camera camera) { if (updateHandInPrecull) { //Don't update pre cull for preview, reflection, or scene view cameras if (camera == null) { camera = preCullCamera; } switch (camera.cameraType) { case CameraType.Preview: #if UNITY_2017_1_OR_NEWER case CameraType.Reflection: #endif case CameraType.SceneView: return; } if (Application.isPlaying && !manualUpdateHasBeenCalledSinceUpdate && _leapController != null) { manualUpdateHasBeenCalledSinceUpdate = true; //Find the left and/or right hand(s) to latch Hand leftHand = null, rightHand = null; LeapTransform precullLeftHand = LeapTransform.Identity; LeapTransform precullRightHand = LeapTransform.Identity; for (int i = 0; i < CurrentFrame.Hands.Count; i++) { Hand updateHand = CurrentFrame.Hands[i]; if (updateHand.IsLeft && leftHand == null) { leftHand = updateHand; } else if (updateHand.IsRight && rightHand == null) { rightHand = updateHand; } } //Determine their new Transforms var interpolationTime = CalculateInterpolationTime(); _leapController.GetInterpolatedLeftRightTransform( interpolationTime + (ExtrapolationAmount * 1000), interpolationTime - (BounceAmount * 1000), (leftHand != null ? leftHand.Id : 0), (rightHand != null ? rightHand.Id : 0), out precullLeftHand, out precullRightHand); bool leftValid = precullLeftHand.translation != Vector.Zero; bool rightValid = precullRightHand.translation != Vector.Zero; transformHands(ref precullLeftHand, ref precullRightHand); //Calculate the delta Transforms if (rightHand != null && rightValid) { _transformArray[0] = Matrix4x4.TRS(precullRightHand.translation.ToVector3(), precullRightHand.rotation.ToQuaternion(), Vector3.one) * Matrix4x4.Inverse(Matrix4x4.TRS(rightHand.PalmPosition.ToVector3(), rightHand.Rotation.ToQuaternion(), Vector3.one)); } if (leftHand != null && leftValid) { _transformArray[1] = Matrix4x4.TRS(precullLeftHand.translation.ToVector3(), precullLeftHand.rotation.ToQuaternion(), Vector3.one) * Matrix4x4.Inverse(Matrix4x4.TRS(leftHand.PalmPosition.ToVector3(), leftHand.Rotation.ToQuaternion(), Vector3.one)); } //Apply inside of the vertex shader Shader.SetGlobalMatrixArray(HAND_ARRAY_GLOBAL_NAME, _transformArray); } } }
public bool IsWeakerThan(Hand h) { return(Fight(h) == -1); }
public bool IsStrongerThan(Hand h) { return(Fight(h) == 1); }
//Uses the interpolable data to reconstruct and fill a frame object public override void DecodeFrame(long frameID, Transform transform, Bone[] leftbones, Bone[] rightbones, List <Finger>[] fingers, Hand LeftHand, Hand RightHand) { int index = 0; if (LPos != Vector3.zero) { DecodeHand(frameID, fingers, true, (transform.rotation * LPos) + transform.position, transform.rotation * LRot, leftbones, LBones, LeftHand); index++; } else { LeftHand.PalmPosition = Vector.Zero; } if (RPos != Vector3.zero) { DecodeHand(frameID, fingers, false, (transform.rotation * RPos) + transform.position, transform.rotation * RRot, rightbones, RBones, RightHand); } else { RightHand.PalmPosition = Vector.Zero; } }
public void SetUp() { _hand = new Hand(); }
public CardsInPokerHandIsNotFiveException(Hand hand) : base($"Poker hand does not have 5 cards. [Hand: {hand.Stringify()}]") { }
//Uses the interpolable data to reconstruct and fill a hand object void DecodeHand(long frameID, List <Finger>[] fingers, bool c, Vector3 p, Quaternion r, Bone[] bones, byte[] fingerBones, Hand outHand) { for (int i = 0; i < 5; i++) { Vector3 PrevJoint = Vector3.zero; Vector3 NextJoint = Vector3.zero; Quaternion boneRot = Quaternion.identity; for (int j = 0; j < 4; j++) { PrevJoint = new Vector3(byteToFloat(fingerBones[(((i * 5) + j) * 3)]), byteToFloat(fingerBones[(((i * 5) + j) * 3) + 1]), byteToFloat(fingerBones[(((i * 5) + j) * 3) + 2])); NextJoint = new Vector3(byteToFloat(fingerBones[(((i * 5) + j + 1) * 3)]), byteToFloat(fingerBones[(((i * 5) + j + 1) * 3) + 1]), byteToFloat(fingerBones[(((i * 5) + j + 1) * 3) + 2])); //Calculate Bone Rotations from offsets if (PrevJoint != NextJoint) { if (i != 0) { boneRot = Quaternion.LookRotation((NextJoint - PrevJoint).normalized, Vector3.Cross((NextJoint - PrevJoint).normalized, Vector3.right).normalized); } else { Vector3 downward = Vector3.Cross((NextJoint - PrevJoint).normalized, Vector3.right).normalized; boneRot = Quaternion.LookRotation((NextJoint - PrevJoint).normalized, Vector3.Cross((NextJoint - PrevJoint).normalized, (c ? -downward : downward)).normalized); } } fillBone(bones[(i * 4) + j], ToWorld(PrevJoint, p, r).ToVector(), ToWorld(NextJoint, p, r).ToVector(), (ToWorld(NextJoint + PrevJoint, p, r) / 2f).ToVector(), p.ToVector(), 1f, 1f, (Bone.BoneType)j, (r * boneRot).ToLeapQuaternion()); } fillFinger(fingers[c ? 0 : 1][i], frameID, (c ? 0 : 1), i, Time.time, ToWorld(NextJoint, p, r).ToVector(), Vector.Zero, (boneRot * Vector3.forward).ToVector(), ToWorld(NextJoint, p, r).ToVector(), 1f, 1f, true, (Finger.FingerType)i, bones[(i * 4) + 0], bones[(i * 4) + 1], bones[(i * 4) + 2], bones[(i * 4) + 3]); } fillArm(outHand.Arm, ToWorld(new Vector3(0f, 0f, -0.3f), p, r).ToVector(), ToWorld(new Vector3(0f, 0f, -0.055f), p, r).ToVector(), ToWorld(new Vector3(0f, 0f, -0.125f), p, r).ToVector(), Vector.Zero, 0.3f, 0.05f, Quaternion.identity.ToLeapQuaternion()); fillHand(outHand, frameID, (c ? 0 : 1), 1f, 0.5f, 100f, 0.5f, 50f, 100f, c, 1f, fingers[c ? 0 : 1], p.ToVector(), p.ToVector(), Vector3.zero.ToVector(), (r * Vector3.up).ToVector(), r.ToLeapQuaternion(), (r * Vector3.forward).ToVector(), ToWorld(new Vector3(0f, 0f, -0.055f), p, r).ToVector()); }
/// <summary> /// IsPlayable - Abstract method which must be implemented to determine if a domino is playable in a hand /// </summary> /// <param name="h">Hand</param> /// <param name="d">Domino to play</param> /// <param name="mustFlip">True if domino must be flipped to be played</param> /// <returns></returns> public abstract bool IsPlayable(Hand h, Domino d, out bool mustFlip);
public abstract void SetLeapHand(Hand hand);
public ActionChange(Hand hand, OutputAction action, bool state) { this.hand = hand; this.action = action; this.state = state; }
public override void RunCommand(TestResult tr, Bone val_bone = default, bool val_bool = false, Eyes val_eyes = default, float val_float = 0, Hand val_hand = default, InputTrackingState val_input_tracking_state = InputTrackingState.None, Quaternion val_quaternion = default, Vector2 val_vector2 = default, Vector3 val_vector3 = default) { h.rot = val_quaternion; }
/// <summary>Converts the first Ace valued at eleven in the Hand to be valued at one.</summary> /// <param name="handConvert">Hand to be converted.</param> private void ConvertAce(Hand handConvert) { handConvert.ConvertAce(); CheckButtons(); DisplayHands(); }
public override HandRanking Catagorize(Hand hand) { return(HandRanking.ThreeOfAKind); }
public override void SetLeapHand(Hand hand) { _hand = hand; }
/// <summary>Deals a Card to a specific Hand.</summary> /// <param name="handAdd">Hand where Card is to be added.</param> /// <param name="hidden">Should the Card be hidden?</param> private void DealCard(Hand handAdd, bool hidden = false) { handAdd.AddCard(new Card(CardList[_index], hidden)); _index++; }
// signal, freq, amplitude, fingercombo, temperature // Update is called once per frame void Update() { temperature = 0; combinationOfFingers = 0; hasBeenInteractedWith = false; if (stopwatch == null) { stopwatch = new Stopwatch(); } controller = new Controller(); Frame frame = controller.Frame(); serialToSend = "<"; if (frame.Hands.Count > 0) { List <Hand> hands = frame.Hands; Hand firstHand = hands[0]; handVelocity = getPalmVelocity(firstHand); serialToSend += sineOrTri + ","; switch (name) { case "Metal": serialToSend += Mathf.Round(metalFrequency * handVelocity) + ","; //serialToSend += Mathf.Round(metalAmplitude) + ","; serialToSend += Mathf.Round(metalAmplitude) + ","; temperature = metalTemperature; break; case "Wood": serialToSend += Mathf.Round(woodFrequency * handVelocity) + ","; //serialToSend += Mathf.Round(metalAmplitude) + ","; serialToSend += Mathf.Round(woodAmplitude) + ","; temperature = woodTemperature; break; case "Brick": serialToSend += Mathf.Round(brickFrequency * handVelocity) + ","; //serialToSend += Mathf.Round(brickAmplitude) + ","; serialToSend += Mathf.Round(brickAmplitude) + ","; temperature = brickTemperature; break; case "Water": serialToSend += Mathf.Round(waterFrequency * handVelocity) + ","; //serialToSend += Mathf.Round(waterAmplitude) + ","; serialToSend += Mathf.Round(waterAmplitude) + ","; temperature = waterTemperature; break; case "Skin": serialToSend += Mathf.Round(skinFrequency * handVelocity) + ","; //serialToSend += Mathf.Round(skinAmplitude) + ","; serialToSend += Mathf.Round(skinAmplitude) + ","; temperature = skinTemperature; break; } // For recording biggest and lowest frequencies dataRecorder.getBigAndLow(serialToSend); //Debug.Log("Hand moves at: " + handVelocity.Magnitude); } // Pinky if (m_Collider.bounds.Contains(collisionHandler.R_pinkyPosition)) { hasBeenInteractedWith = true; //combinationOfFingers += 1; //Debug.Log("CollisionScript: R_pinky touches: " + name); } // Ring if (m_Collider.bounds.Contains(collisionHandler.R_ringPosition)) { hasBeenInteractedWith = true; //combinationOfFingers += 2; //Debug.Log("CollisionScript: R_ring touches: " + name); } // Middle if (m_Collider.bounds.Contains(collisionHandler.R_middlePosition)) { hasBeenInteractedWith = true; //combinationOfFingers += 4; //Debug.Log("CollisionScript: R_middle touches: " + name); } // Index if (m_Collider.bounds.Contains(collisionHandler.R_indexPosition)) { hasBeenInteractedWith = true; combinationOfFingers += 1; Debug.Log(name + " contains " + collisionHandler.R_indexPosition); Debug.Log("CollisionScript: R_index touches: " + name); } // Thumb if (m_Collider.bounds.Contains(collisionHandler.R_thumbPosition)) { hasBeenInteractedWith = true; combinationOfFingers += 2; //Debug.Log("CollisionScript: R_thumb touches " + name); } //serialToSend += ">"; serialToSend += combinationOfFingers.ToString() + "," + temperature + ">"; if (hasBeenInteractedWith) { arduino.SendToArduino(serialToSend); //Debug.Log(serialToSend); if (!stopwatch.IsRunning) { stopwatch.Start(); } } else { arduino.SendToArduino("<sine,0,0,0,0>"); if (stopwatch.IsRunning) { stopwatch.Stop(); } } // Only send to arduino if a material has been interacted with }
// Update is called once per frame void Update() { Frame frame = controller.Frame(); if (!started && scene.name == "Labyrinth") //is tutorial { List <Hand> hands = frame.Hands; if (hands.Count == 0) { return; } int numberFingers = 0; handplayer = hands[0]; fingers = handplayer.Fingers; foreach (Finger f in fingers) { if (f.IsExtended) { numberFingers++; } } if ((handplayer.GetThumb().IsExtended&& numberFingers == 1) || Input.GetKey("1")) { iniciarJuego(); } return; } if (frame != null) { List <Hand> hands = frame.Hands; if (hands.Count == 0) { transform.eulerAngles = new Vector3(0f, 0f, 0f); //poner a una posicion default return; } actPosition = hands[0]; Quaternion quat = actPosition.Basis.rotation.ToQuaternion();//* Time.deltaTime; quat.z = -quat.z; //movement fixs, just in case it goes crazy //inclinación vertical if (quat.x > 0.2f) { quat.x = 0.2f; } else if (quat.x < -0.25f) { quat.x = -0.25f; } //rotacion mano if (quat.y > 0.3f) { quat.y = 0.3f; } else if (quat.y < -0.3f) { quat.y = -0.3f; } //inclinación lateral if (quat.z > 0.3f) { quat.z = 0.3f; } else if (quat.z < -0.3f) { quat.z = -0.3f; } transform.rotation = quat; antPosition = actPosition; } }
private bool PlayLogic(ref ICollection <IBotTask> tasks) { var leastBusyRow = Board.RangedSize < Board.MeleeSize ? Card.Rows.Ranged : Card.Rows.Melee; #region Thin foglet // consume if (Board.Count(typeof(Foglet)) == 1) { var foglet = Board.GetCard(typeof(Foglet)); var placePoint = new Point(foglet.Area.Right, foglet.Y + foglet.Height / 2); if (Hand.Contain(typeof(Brewess))) { return(Hand.Play(typeof(Brewess), out tasks, leastBusyRow, placePoint)); } if (Hand.Contain(typeof(CelaenoHarpy))) { return(Hand.Play(typeof(CelaenoHarpy), out tasks, leastBusyRow, placePoint)); } if (Hand.Contain(typeof(Cyclops))) { return(Hand.Play(typeof(Cyclops), out tasks, leastBusyRow, placePoint)); } } // place foglet if (Hand.Contain(typeof(Foglet)) && (Hand.Contain(typeof(Cyclops)) || Hand.Contain(typeof(Brewess)) || Hand.Contain(typeof(CelaenoHarpy)))) { return(Hand.Play(typeof(Foglet), out tasks, Card.Rows.Melee)); } #endregion #region Blow brewess/cyclop if we alredy thinned foglet (or its too late) if (Extra.CurrentRound == Rounds.Draw || GameMemory.InGraveyard(typeof(Foglet))) { if (Hand.Contain(typeof(Cyclops))) { return(Hand.Play(typeof(Cyclops), out tasks)); } if (Hand.Contain(typeof(Brewess))) { return(Hand.Play(typeof(Brewess), out tasks)); } } if (Extra.CurrentRound == Rounds.Draw && Hand.Contain(typeof(Golyat)) && !Hand.Contain(typeof(Katakan)) && !Board.Contain(typeof(Katakan)) && !Hand.Contain(typeof(Foglet)) && !Board.Contain(typeof(Foglet))) { if (Hand.Contain(typeof(Cyclops))) { return(Hand.Play(typeof(Cyclops), out tasks)); } if (Hand.Contain(typeof(Brewess))) { return(Hand.Play(typeof(Brewess), out tasks)); } if (Hand.Contain(typeof(CelaenoHarpy))) { return(Hand.Play(typeof(CelaenoHarpy), out tasks)); } } #endregion #region Wild hunt raider // Manually adding extra wild hunt rider to played list if (Board.Count(typeof(WildHuntRider)) == 2 && GameMemory.GetGy().Count(card => card == typeof(WildHuntRider)) == 1) { GameMemory.RegisterCard(typeof(WildHuntRider)); } // Play wild hunt raider if we can (easy check) if (Extra.EnemyScore <= 4 && Hand.Count(typeof(WildHuntRider)) == 1) { return(Hand.Play(typeof(WildHuntRider), out tasks, Card.Rows.Ranged)); } #endregion #region Small thrive if (Hand.Contain(typeof(Nekker))) { return(Hand.Play(typeof(Nekker), out tasks, leastBusyRow)); } if (Hand.Contain(typeof(Wyvern)) && Extra.EnemyScore >= 3) { return(Hand.Play(typeof(Wyvern), out tasks, Card.Rows.Melee)); } if (Hand.Contain(typeof(NekkerWarrior))) { return(Hand.Play(typeof(NekkerWarrior), out tasks, leastBusyRow)); } if (Hand.Contain(typeof(AlphaWerewolf)) && HaveOtherImmuneShit()) { return(Hand.Play(typeof(AlphaWerewolf), out tasks, leastBusyRow)); } #endregion #region Plumard // Play 2 plumard if we can if (Hand.Contain(typeof(Plumard)) && Extra.EnemyScore >= 3 && Board.Count(typeof(Plumard)) + Hand.Count(typeof(Plumard)) >= 2) { return(Hand.Play(typeof(Plumard), out tasks, leastBusyRow)); } #endregion #region Play medium sized threats if (Hand.Contain(typeof(Katakan))) { return(Hand.Play(typeof(Katakan), out tasks, leastBusyRow)); } if (Hand.Contain(typeof(WeavessIncantation))) { if (Hand.Contain(typeof(PrimordialDao)) || Hand.Contain(typeof(Golyat)) || Hand.Contain(typeof(OldSpeartipAsleep)) || Hand.Contain(typeof(OldSpeartip)) || Hand.Contain(typeof(CountCaldwell)) || Hand.Contain(typeof(IceGiant))) { WeavessIncantationMode = true; return(Hand.Play(typeof(WeavessIncantation), out tasks, Card.Rows.Melee)); } } if (Hand.Contain(typeof(IceGiant))) { return(Hand.Play(typeof(IceGiant), out tasks, leastBusyRow)); } if (Hand.Contain(typeof(PrimordialDao))) { return(Hand.Play(typeof(PrimordialDao), out tasks, leastBusyRow)); } if (Hand.Contain(typeof(OldSpeartipAsleep))) { return(Hand.Play(typeof(OldSpeartipAsleep), out tasks, leastBusyRow)); } if (Hand.Contain(typeof(OldSpeartip))) { return(Hand.Play(typeof(OldSpeartip), out tasks, leastBusyRow)); } #endregion #region Crones if (Hand.Contain(typeof(Whispess)) && Extra.EnemyScore >= 3) { return(Hand.Play(typeof(Whispess), out tasks)); } if (Hand.Contain(typeof(Weavess)) && SomethingToBuff()) { return(Hand.Play(typeof(Weavess), out tasks, leastBusyRow)); } #endregion #region Swallow + Parasyte if (Board.Count() >= 2 && Hand.Contain(typeof(Swallow)) && !Board.Contain(typeof(TacticalAdvantage))) { return(Hand.Play(typeof(Swallow), out tasks)); } if (Board.Count() >= 2 && Hand.Contain(typeof(Parasite)) && !Board.Contain(typeof(TacticalAdvantage))) { return(Hand.Play(typeof(Parasite), out tasks)); } #endregion #region Consume if (Extra.CurrentRound != Rounds.FirstRound && Hand.Contain(typeof(Ghoul))) { if (GameMemory.InGraveyard(typeof(IceGiant)) || GameMemory.InGraveyard(typeof(Weavess)) || GameMemory.InGraveyard(typeof(Whispess)) || GameMemory.InGraveyard(typeof(Brewess)) || GameMemory.InGraveyard(typeof(Cyclops))) { GhoulMode = true; return(Hand.Play(typeof(Ghoul), out tasks, Card.Rows.Melee)); } } if (Extra.CurrentRound != Rounds.FirstRound && Hand.Contain(typeof(Ozzrel))) { if (GameMemory.InGraveyard(typeof(OldSpeartipAsleep)) || GameMemory.InGraveyard(typeof(OldSpeartip)) || GameMemory.InGraveyard(typeof(Golyat)) || GameMemory.InGraveyard(typeof(CountCaldwell)) || GameMemory.InGraveyard(typeof(PrimordialDao))) { OzzrelMode = true; return(Hand.Play(typeof(Ozzrel), out tasks, Card.Rows.Ranged)); } } #endregion #region Leader logic if (Extra.CurrentRound != Rounds.FirstRound && Hand.Contain(typeof(WoodlandSpirit))) { LeaderBuffMode = true; return(Hand.Play(typeof(WoodlandSpirit), out tasks)); } if (LeaderBuffMode && !Hand.Contain(typeof(WoodlandSpirit))) { LeaderBuffMode = false; foreach (var card in FromHighToLowStr.Reverse()) { if (Hand.Contain(card)) { return(Hand.Play(card, out tasks)); } } } #endregion #region Katakan->Consume if (Board.Contain(typeof(Katakan))) { var katakan = Board.GetCard(typeof(Katakan)); var placePoint = new Point(katakan.Area.Right, katakan.Y + katakan.Height / 2); if (Hand.Contain(typeof(Brewess))) { tasks.Add(new TooltipTask("Katakan->Consume")); return(Hand.Play(typeof(Brewess), out tasks, default, placePoint));
//Updates the game logic based on discrete physics updates void FixedUpdate() { //If counting down before player can play, disable movement if (countingDown) { timeLeft = (int)(countDownTimer - Time.time); if (timeLeft <= 0) { countingDown = false; } transform.rigidbody.useGravity = false; } //if out of fuel else if (outOfFuel) { //Add a downward force for five frames to help speed up the slow down process if (outOfFuelCount < 5) { transform.rigidbody.AddForce(-transform.up * thrustPower, ForceMode.Force); outOfFuelCount++; } } //Else, game on! else { //Turn gravity on transform.rigidbody.useGravity = true; //Update where the shuttle is relative to ground AtmosphereCheck(); //If shuttle has reached orbit threshold, end the level if (inOrbit) { //Application.loadedLevel(0); } //Manage fuel use ManageFuel(); //Get the frame info from the leap motion controller Frame frame = leapController.Frame(); //If there are 2 hands in the current Leap Frame update leap logic if (frame.Hands.Count >= 2) { //Turn on thrusters leftThruster.Play(); rightThruster.Play(); mainThruster.Play(); //Assign the hands to variables Hand leftHand = GetLeftMostHand(frame); Hand rightHand = GetRightMostHand(frame); //Takes the average forward tilt of palms, used for x rotation Vector3 avgPalmForward = (frame.Hands[0].Direction.ToUnity() + frame.Hands[1].Direction.ToUnity()) * 0.5f; //Gets the Vector difference between the palm positions Vector3 handDiff = leftHand.PalmPosition.ToUnityScaled() - rightHand.PalmPosition.ToUnityScaled(); //Get the current shuttle rotation, then apply the hand's height difference to rotate about the shuttle's z axis Vector3 newRot = transform.localRotation.eulerAngles; //newRot.z = -handDiff.y * 10.0f; newRot.z = -handDiff.y * 20.0f; //Uses the difference between the hands z(depth) and the z rotation to rotate the shuttle about the y axis //newRot.y += handDiff.z * 1.5f - newRot.z * 0.09f * transform.rigidbody.velocity.magnitude; newRot.y += handDiff.z * 3.0f - newRot.z * 0.03f * transform.rigidbody.velocity.magnitude; //Uses the palm's tilt to rotate the shuttle about the x axis //newRot.x = -(avgPalmForward.y - 0.1f) * 100.0f; newRot.x = -(avgPalmForward.y - 0.1f) * 100.0f; //Apply the rotation & force to the transform transform.localRotation = Quaternion.Slerp(transform.localRotation, Quaternion.Euler(newRot), 0.1f); // transform.rigidbody.AddForce(transform.up * thrustPower, ForceMode.Force); transform.rigidbody.AddForceAtPosition(transform.up * thrustPower, thrustPos.position, ForceMode.Force); //transform.rigidbody.velocity = transform.up * thrustPower; } //Else Fall to deaths else { //Turn off thrusters leftThruster.Stop(); rightThruster.Stop(); mainThruster.Stop(); } } }
/// <summary> /// Returns current potential hand value /// </summary> private int GetHandValue() { var value = Hand.GetCards().Sum(card => card.Value); if (Hand.Contain(typeof(Ghoul))) { if (GameMemory.InGraveyard(typeof(IceGiant))) { value += 7; } else if (GameMemory.InGraveyard(typeof(Cyclops))) { value += 5; } else if (GameMemory.InGraveyard(typeof(Werewolf)) || GameMemory.InGraveyard(typeof(AlphaWerewolf)) || GameMemory.InGraveyard(typeof(NekkerWarrior)) || GameMemory.InGraveyard(typeof(WildHuntRider))) { value += 4; } } if (Hand.Contain(typeof(Ozzrel))) { if (GameMemory.InGraveyard(typeof(OldSpeartip))) { value += 12; } else if (GameMemory.InGraveyard(typeof(CountCaldwell)) || GameMemory.InGraveyard(typeof(Golyat))) { value += 10; } else if (GameMemory.InGraveyard(typeof(OldSpeartipAsleep)) || GameMemory.InGraveyard(typeof(PrimordialDao))) { value += 9; } else if (GameMemory.InGraveyard(typeof(IceGiant))) { value += 7; } } if (Hand.Contain(typeof(WeavessIncantation))) { if (Hand.Contain(typeof(OldSpeartip))) { value += 12; } else if (Hand.Contain(typeof(CountCaldwell)) || Hand.Contain(typeof(Golyat))) { value += 10; } else if (Hand.Contain(typeof(OldSpeartipAsleep)) || Hand.Contain(typeof(PrimordialDao))) { value += 9; } else if (Hand.Contain(typeof(IceGiant))) { value += 7; } } return(value); }
public float getPalmVelocity(Hand hand) { return((hand.PalmVelocity * Time.deltaTime).Magnitude); }
public Hand Create(Game game, List <User> users, List <User> previouslyPlayers, int handCount) { var hand = new Hand { Id = Guid.NewGuid(), Game = game, Started = game.Started.AddMinutes(5 * handCount), }; /* * choose 2-8 players for game * * picks players at random * keeps track of each player it has asked, so doesn't ask them twice * this looks at players availability and a small random number * if they have already played in that game it increases the odds they will continue to play further hands * if they are available adds to hand * * if no one available close hand and game */ var players = new List <User>(); var numOfPlayers = _random.Next(2, 8); var numberOfUnavailableUsers = 0; var usersCount = users.Count; if (usersCount < numOfPlayers) { return(null); } while (players.Count < numOfPlayers && usersCount - numberOfUnavailableUsers > 0) { if (previouslyPlayers != null && previouslyPlayers.Any()) { foreach (var player in previouslyPlayers) { if (player.IsAvailable()) { AddPlayerToList(game, players, hand, player); } } } var user = users[_random.Next(0, usersCount - 1)]; if (user.IsAvailable()) { AddPlayerToList(game, players, hand, user); } else { numberOfUnavailableUsers++; } } if (!players.Any()) { return(null); } hand.Players = players; return(hand); }
private bool MulliganLogic(out ICollection <IBotTask> tasks) { tasks = new List <IBotTask>(); #region Replace some pairs if (Mulligan.Count(typeof(WildHuntRider)) == 2) { var card = Mulligan.GetCard(typeof(WildHuntRider)); return(AddMulliganTask(tasks, card, "Replace 2 riders")); } if (Mulligan.Count(typeof(Foglet)) == 2) { var card = Mulligan.GetCard(typeof(Foglet)); return(AddMulliganTask(tasks, card, "Replace 2 foglets")); } if (Mulligan.Count(typeof(Werewolf)) == 2) { var card = Mulligan.GetCard(typeof(Werewolf)); return(AddMulliganTask(tasks, card, "Replace 2 werewolfs")); } if (Mulligan.Count(typeof(CelaenoHarpy)) == 2) { var card = Mulligan.GetCard(typeof(CelaenoHarpy)); return(AddMulliganTask(tasks, card, "Replace 2 celaeno")); } if (IsRound1()) { if (Mulligan.Count(typeof(Nekker)) == 2) { var card = Mulligan.GetCard(typeof(Nekker)); return(AddMulliganTask(tasks, card, "Replace 2 nekkers")); } } #endregion #region Already tried to thin foglet if (GameMemory.InGraveyard(typeof(Foglet)) && Hand.Contain(typeof(Foglet))) { var card = Mulligan.GetCard(typeof(Foglet)); return(AddMulliganTask(tasks, card, "Already tried to thin foglet")); } #endregion #region Replace ozzrel and ghouls if (IsRound1()) { if (Mulligan.Contain(typeof(Ghoul))) { var card = Mulligan.GetCard(typeof(Ghoul)); return(AddMulliganTask(tasks, card, "Don't need ghoul R1")); } if (Mulligan.Contain(typeof(Ozzrel))) { var card = Mulligan.GetCard(typeof(Ozzrel)); return(AddMulliganTask(tasks, card, "Don't need ozzrel R1")); } } #endregion #region Replace weak card in R2+ if (NotRound1()) { if (Mulligan.Contain(typeof(Foglet)) && GameMemory.InGraveyard(typeof(Foglet))) { var card = Mulligan.GetCard(typeof(Foglet)); return(AddMulliganTask(tasks, card, "Don't need Foglet in R2+")); } if (Mulligan.Contain(typeof(Plumard))) { var card = Mulligan.GetCard(typeof(Plumard)); return(AddMulliganTask(tasks, card, "Don't need Plumard in R2+")); } if (Mulligan.Contain(typeof(Nekker))) { var card = Mulligan.GetCard(typeof(Nekker)); return(AddMulliganTask(tasks, card, "Don't need Nekker in R2+")); } if (Mulligan.Contain(typeof(Wyvern))) { var card = Mulligan.GetCard(typeof(Wyvern)); return(AddMulliganTask(tasks, card, "Don't need Wyvern in R2+")); } if (Mulligan.Contain(typeof(NekkerWarrior))) { var card = Mulligan.GetCard(typeof(NekkerWarrior)); return(AddMulliganTask(tasks, card, "Don't need NekkerWarrior in R2+")); } if (Mulligan.Contain(typeof(Brewess))) { var card = Mulligan.GetCard(typeof(Brewess)); return(AddMulliganTask(tasks, card, "Don't need Brewess in R2+")); } } #endregion tasks.Add(new FinishMulliganTask()); return(false); }
public AblenkungsmanoeverKarte(int value, Hand hand, Deck deck) : base(value, hand, deck) { titel = "Finte"; kartenphase = "Spiele unmittelbar nach einem Würfelwurf."; text = "Entweder ein einzelener oder alle\nWürfel dieses Wurfs werden neue\ngeworfen"; }
public override void Enter() { Hand[] result = new Hand[m_Owner.Players.Length]; for (int i = 0; i < m_Owner.Players.Length; i++) { Card[] hand = m_Owner.OnHand[i].Concat(m_Owner.OnTable).ToArray(); if ((result[i] = Evaluator.isRoyalFlush(hand)) != null) { continue; } else if ((result[i] = Evaluator.isStraightFlush(hand)) != null) { continue; } else if ((result[i] = Evaluator.isFours(hand)) != null) { continue; } else if ((result[i] = Evaluator.isFlush(hand)) != null) { continue; } else if ((result[i] = Evaluator.isFullHouse(hand)) != null) { continue; } else if ((result[i] = Evaluator.isStraight(hand)) != null) { continue; } else if ((result[i] = Evaluator.isThrees(hand)) != null) { continue; } else if ((result[i] = Evaluator.isTwoPairs(hand)) != null) { continue; } else if ((result[i] = Evaluator.isPairs(hand)) != null) { continue; } else { result[i] = new Hand(Size.HIGH_CARD, hand, null); } } if (result[0].Size == result[1].Size) { Card highCardOne = m_Owner.OnHand[0].OrderBy(x => x.Rank).Last();; Card highCardTwo = m_Owner.OnHand[1].OrderBy(x => x.Rank).Last();; switch (result[0].Size) { case Size.ROYAL_FLUSH: m_Owner.UIController.SetResultText("Draw!"); break; case Size.STRAIGHT_FLUSH: case Size.FOUR_OF_A_KIND: case Size.FLUSH: case Size.STRAIGHT: case Size.THREE_OF_A_KIND: case Size.TWO_PAIR: case Size.ONE_PAIR: highCardOne = result[0].GetHighestCard(); highCardTwo = result[1].GetHighestCard(); break; case Size.FULL_HOUSE: Hand highResultOne = Evaluator.isThrees(result[0].Cards); Hand highReusltTwo = Evaluator.isThrees(result[1].Cards); highCardOne = highResultOne.GetHighestCard(); highCardTwo = highReusltTwo.GetHighestCard(); break; default: highCardOne = m_Owner.OnHand[0].OrderBy(x => x.Rank).Last(); highCardTwo = m_Owner.OnHand[1].OrderBy(x => x.Rank).Last(); break; } if (highCardOne.Rank > highCardTwo.Rank) { m_Owner.UIController.SetResultText("Player One Wins!"); } else if (highCardOne.Rank < highCardTwo.Rank) { m_Owner.UIController.SetResultText("Player Two Wins!"); } else { m_Owner.UIController.SetResultText("Draw!"); } } else if (result[0].Size < result[1].Size) { m_Owner.UIController.SetResultText("Player One Wins!!"); } else { m_Owner.UIController.SetResultText("Player Two Wins!!"); } m_Owner.Players[0].SetHand(result[0].Size.ToString()); m_Owner.Players[1].SetHand(result[1].Size.ToString()); Clean(); }