private void SwapCards(CCard CardA, CCard CardB) { int TempSuit = CardA.GetSuit(); int TempValue = CardA.GetValue(); CardA.SetSuit(CardB.GetSuit()); CardA.SetValue(CardB.GetValue()); CardB.SetSuit(TempSuit); CardB.SetValue(TempValue); }
public bool MoveCard(int SlotX, int SlotY) { CCard CurCard = GetCard(SlotX, SlotY); if (m_WaitingForKing) { if (CurCard.GetValue() == 13) { CMove Move = new CMove(0, m_WaitingKingY, SlotX, SlotY, m_NumActionsInGame++); SwapCards(Move); m_WaitingForKing = false; return(true); } } else { // make sure we clicked on a hole if (CurCard.GetValue() == 1) { // figure out what card we want to put here if (SlotX == 0) { // we clicked on a king only slot m_WaitingForKing = true; m_WaitingKingY = SlotY; return(true); } else { CCard CardToLeft = GetCard(SlotX - 1, SlotY); if (CardToLeft.GetValue() < 3) { return(false); } // find the card that we want to put here for (int Y = 0; Y < (int)BoardSize.HEIGHT; Y++) { for (int X = 0; X < (int)BoardSize.WIDTH; X++) { CCard CheckCard = GetCard(X, Y); if (CheckCard.GetSuit() == CardToLeft.GetSuit() && CheckCard.GetValue() == CardToLeft.GetValue() - 1) { CMove Move = new CMove(X, Y, SlotX, SlotY, m_NumActionsInGame++); SwapCards(Move); return(true); } } } } } } return(false); }
public bool SpaceIsClickable(int CardX, int CardY) { if (CardX == 0) { return(true); } CCard card = GetCard(CardX, CardY); CCard CardToLeft = GetCard(CardX - 1, CardY); if ((card.GetValue() == (int)CCard.CARD_VALUE.VALUE_ACE) && CardToLeft.GetValue() > 2) { return(true); } return(false); }
private bool CardIsInOrder(int SlotX, int SlotY) { CCard CurCard = GetCard(SlotX, SlotY); if (CurCard.GetValue() - (13 - SlotX) == 0) { // we know the card is in the right place is everything to the left of it // in the right place and the same suit for (int i = 0; i < SlotX; i++) { CCard TestCard = GetCard(i, SlotY); if (CurCard.GetSuit() != TestCard.GetSuit() || TestCard.GetValue() - (13 - i) != 0) { return(false); } } return(true); } return(false); }
public void DrawCard(Graphics2D DestGraphics, int CardX, int CardY) { double StartX = CardX * CARD_WIDTH + m_BoardX; double StartY = CardY * CARD_HEIGHT + m_BoardY; RectangleDouble CardBounds = new RectangleDouble(StartX + 1.5, StartY + 1.5, StartX + CARD_WIDTH - 1.5, StartY + CARD_HEIGHT - 1.5); RoundedRect CardFiledRoundedRect = new RoundedRect(CardBounds.Left, CardBounds.Bottom, CardBounds.Right, CardBounds.Top, 5); Stroke CardRectBounds = new Stroke(CardFiledRoundedRect); CardRectBounds.width(1); CCard Card = MomsGame.GetCard(CardX, CardY); int CardValue = Card.GetValue(); int CardSuit = Card.GetSuit(); String ValueString = "Uninitialized "; if (CardValue > (int)CCard.CARD_VALUE.VALUE_ACE) { DestGraphics.SetTransform(Affine.NewIdentity()); DestGraphics.Render(CardRectBounds, new RGBA_Bytes(0, 0, 0)); if (CardValue > 10) { switch (CardValue) { case 11: ValueString = "J"; break; case 12: ValueString = "Q"; break; case 13: ValueString = "K"; break; default: throw new Exception(); } } else { ValueString = CardValue.ToString(); } TextWidget stringToDraw = new TextWidget(ValueString, 10); RectangleDouble textBounds = stringToDraw.Printer.LocalBounds; DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 2, CardBounds.Top - 8 - textBounds.Height / 2)); DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0)); DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 4 - textBounds.Width, CardBounds.Bottom + 9 - textBounds.Height / 2)); DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0)); RGBA_Bytes SuitColor = new RGBA_Bytes(0, 0, 0); IVertexSource suitPath = new PathStorage(); switch (CardSuit) { case (int)CCard.CARD_SUIT.SUIT_DIAMOND: { SuitColor = new RGBA_Bytes(0xFF, 0x11, 0x11); suitPath = m_DiamondShape; } break; case (int)CCard.CARD_SUIT.SUIT_CLUB: { SuitColor = new RGBA_Bytes(0x22, 0x22, 0x66); suitPath = new FlattenCurves(m_ClubShape); } break; case (int)CCard.CARD_SUIT.SUIT_HEART: { SuitColor = new RGBA_Bytes(0xBB, 0x00, 0x00); suitPath = new FlattenCurves(m_HeartShape); } break; case (int)CCard.CARD_SUIT.SUIT_SPADE: { SuitColor = new RGBA_Bytes(0x00, 0x00, 0x00); suitPath = new FlattenCurves(m_SpadeShape); } break; default: break; } textBounds = stringToDraw.Printer.LocalBounds; if (CardValue < 11) { for (int CurDot = 0; CurDot < CardValue; CurDot++) { double OffsetX = 0, OffsetY = 0; GetSuitOffset(ref OffsetX, ref OffsetY, CurDot, (int)CardValue); DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + OffsetX, CardBounds.Bottom + OffsetY)); DestGraphics.Render(suitPath, SuitColor); } } else { DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + 9, CardBounds.Bottom + 17)); DestGraphics.Render(suitPath, SuitColor); DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Right - 9, CardBounds.Top - 17)); DestGraphics.Render(suitPath, SuitColor); stringToDraw = new TextWidget(ValueString, 22); textBounds = stringToDraw.Printer.LocalBounds; DestGraphics.SetTransform(Affine.NewTranslation(-1 + CardBounds.Left + CardBounds.Width / 2 - textBounds.Width / 2, CardBounds.Bottom + CardBounds.Height / 2 - textBounds.Height / 2)); DestGraphics.Render(stringToDraw.Printer, new RGBA_Bytes(0, 0, 0)); } } else { RGBA_Bytes HoleColor = new RGBA_Bytes(0, 0, 0); String OpenSpaceString; if (!MomsGame.SpaceIsClickable(CardX, CardY)) { HoleColor = new RGBA_Bytes(0xf8, 0xe2, 0xe8); OpenSpaceString = "X"; } else { HoleColor = new RGBA_Bytes(0xe1, 0xe0, 0xf6); OpenSpaceString = "O"; } TextWidget stringToDraw = new TextWidget(OpenSpaceString, 35); RectangleDouble Size = stringToDraw.Printer.LocalBounds; DestGraphics.SetTransform(Affine.NewTranslation(CardBounds.Left + CardBounds.Width / 2 - Size.Width / 2, CardBounds.Bottom + CardBounds.Height / 2 - Size.Height / 2)); DestGraphics.Render(stringToDraw.Printer, HoleColor); } }