public CardGameQuestion(UserLogicModel user, string question, string[] answers, GameCardGame cardGame) { User = user; Question = question; Answers = answers; CardGame = cardGame; }
public static int AskQuestion(UserLogicModel user, string question, string[] answers, GameCardGame cardGame) { cardGame.Emulating = false; if (cardGame.Answers.Count - 1 > cardGame.AnswerIndex) { cardGame.Emulating = true; return cardGame.Answers[cardGame.AnswerIndex++].Value; //todo .value } var m = new CardGameQuestion(user, question, answers, cardGame); var answer = Fiber<CardGameAnswer>.Yield(new FiberYieldResponse(FiberYieldResponseType.AskQuestion, m)); cardGame.AnswerIndex++; return answer == null ? 0 : answer.Value; }
public static void Break(int lineNumber, GameCardGame cardGame, Func<string, string> varLookup) { if (cardGame.Emulating) return; var yieldObject = new FiberYieldResponse(FiberYieldResponseType.Break, lineNumber - 1, ""); while (true) { var answ = Fiber<FiberYieldResponse>.Yield(yieldObject); if (answ == null) { //continue return; } if (answ.VariableLookup != null) { yieldObject = new FiberYieldResponse(FiberYieldResponseType.VariableLookup, 0, varLookup(answ.VariableLookup)); continue; } break; } }
public void drawArea(GameCardGame mainArea) { newDrawArea(mainArea); foreach (var ta in mainArea.TextAreas) { // gameboard.Context.FillStyle = "rgba(200, 0, 200, 0.5)"; // gameboard.Context.FillText(ta.Text, ta.X * scale.X, ta.Y * scale.Y); } }
public void Draw(GameCardGame data) { foreach (var space in data.Spaces) { space.Appearance = fixAppearance(space.Appearance); foreach (var card in space.Pile.Cards) { card.Appearance = fixAppearance(card.Appearance); } } drawArea(data); }
private void newDrawArea(GameCardGame mainArea) { //jQuery.Select("#dvGame").Children().Remove(); var scale = new Point(Document.DocumentElement.ClientWidth / mainArea.Size.Width * .9, ( Document.DocumentElement.ClientHeight - 250 ) / mainArea.Size.Height * .9); //ExtensionMethods.debugger(null); var sl = mainArea.Spaces.Count; /* for (int spaceIndex = 0; spaceIndex < sl; spaceIndex++) { var space = mainArea.Spaces[spaceIndex]; var jf = findSpace(space).OuterElement; for (int i = 0; i < resetStyles.Length; i++) { jf.Style[resetStyles[i]] = null; } l = space.Pile.Cards.Count; for (int index = 0; index < l; index++) { var card = space.Pile.Cards[index]; var m = findCard(space, card); for (int i = 0; i < resetStyles.Length; i++) { m.OuterElement.Style[resetStyles[i]] = null; m.Image.Style[resetStyles[i]] = null; } } } */ for (int index = 0; index < sl; index++) { var space = mainArea.Spaces[index]; var vertical = space.Vertical; var spaceDiv = findSpace(space); // var spaceDivJ = jQuery.FromElement(spaceDiv); //ExtensionMethods.debugger(); var cl = space.Appearance.Effects.Count; for (int i = 0; i < cl; i++) { var effect = space.Appearance.Effects[i]; effect.Build(spaceDiv); } spaceDiv.OuterElementStyle.Width = ( space.Width * scale.X ).px(); spaceDiv.OuterElementStyle.Height = ( space.Height * scale.Y ).px(); // gameboard.Context.FillRect(space.X * scale.X, space.Y * scale.Y, space.Width * scale.X, space.Height * scale.Y); var spaceScale = new Point(space.Width / space.Pile.Cards.Count, space.Height / space.Pile.Cards.Count); var j = 0; var numOfCards = space.Pile.Cards.Count; for (int i = 0; i < numOfCards; i++) { var card = space.Pile.Cards[i]; var xx = 0.0; var yy = 0.0; switch (space.ResizeType) { case TableSpaceResizeType.Static: if (vertical) yy = card.Value * scale.Y / 2; else xx = card.Value * scale.X / 2; break; case TableSpaceResizeType.Grow: xx = ( !vertical ? ( j * spaceScale.X * scale.X ) : 0 ); yy = ( vertical ? ( j * spaceScale.Y * scale.Y ) : 0 ); break; default: xx = ( !vertical ? ( j * spaceScale.X * scale.X ) : 0 ); yy = ( vertical ? ( j * spaceScale.Y * scale.Y ) : 0 ); break; } var cardDiv = findCard(space, card); xx -= cardDiv.OuterElementStyle.Width.nopx() / 2; yy -= cardDiv.OuterElementStyle.Height.nopx() / 2; cardDiv.OuterElementStyle.BorderRadius = "5px"; cardDiv.OuterElementStyle.BoxShadow = "3px 3px 2px #2c2c2c"; styleAppearanceFromSpace(cardDiv, j, space); styleAppearance(cardDiv, card.Appearance); spaceDiv.OuterElementStyle.Left = ( ( space.X ) * scale.X ).px(); spaceDiv.OuterElementStyle.Top = ( ( space.Y ) * scale.Y ).px(); //cardDiv.OuterElement.Style["transform"] = 0.0.TransformRotate(); cardDiv.OuterElementStyle.Left = ( xx + ( vertical ? space.Width * scale.X / 2 : 0 ) ).px(); cardDiv.OuterElementStyle.Top = ( yy + ( !vertical ? space.Height * scale.Y / 2 : 0 ) ).px(); cardDiv.OuterElementStyle.Transform = space.Appearance.InnerStyle.Rotate.TransformRotate(); cardDiv.OuterElementStyle.SetStyle(cardDiv.OuterElement); FixBrowserPrefixes(cardDiv.OuterElement.Style); // spaceDiv.AppendChild(cardDiv); j++; //effects } var el = space.Appearance.Effects.Count; for (int i = 0; i < el; i++) { var effect = space.Appearance.Effects[i]; effect.TearDown(spaceDiv); } } foreach (var space in mainArea.Spaces) { findSpace(space).OuterElementStyle.SetStyle(findSpace(space).OuterElement); foreach (var card in space.Pile.Cards) { // var m = findCard(space, card); findSpace(space).OuterElementStyle.SetStyle(findSpace(space).OuterElement); /* m.ImageStyle = new MyStyle(); m.OuterElementStyle = new MyStyle(); */ } } /* foreach (var ta in mainArea.TextAreas) { gameboard.Context.FillStyle = "rgba(200, 0, 200, 0.5)"; gameboard.Context.FillText(ta.Text, ta.X * scale.X, ta.Y * scale.Y); }*/ }
public static void Break(BreakInfoObject breakInfo, GameCardGame cardGame, Func<string, string> varLookup) { /* if (cardGame.Emulating) return;*/ if (cardGame != null && cardGame.DebugInfo != null) { if (cardGame.DebugInfo.Breakpoints.Contains(breakInfo.Line) || (!!(dynamic)cardGame.DebugInfo.StepThrough && cardGame.DebugInfo.StepThrough != StepType.Continue)) { if (cardGame.DebugInfo.LastBrokenLine == breakInfo.Line) return; cardGame.DebugInfo.LastBrokenLine = breakInfo.Line; var wasLastBreakLast = cardGame.DebugInfo.LastWasEndOfFunction; var wasLastIndexBreakLast = cardGame.DebugInfo.LastWasEndOfFunctionIndex; cardGame.DebugInfo.LastWasEndOfFunction = breakInfo.IsLast; if (cardGame.DebugInfo.LastWasEndOfFunction) { cardGame.DebugInfo.LastWasEndOfFunctionIndex = breakInfo.Funcdef; } //step out // if step into/over // if end of function is reached (determined at parse time) then // allow lastfunc to != funcdef // if step out // wait until end of function, trigger next debug? switch (cardGame.DebugInfo.StepThrough) { case StepType.Into: if (cardGame.DebugInfo.LastFunction == breakInfo.Funcdef) { Console.WriteLine("step over happened " + cardGame.DebugInfo.LastFunction + " == " + breakInfo.Funcdef); } else if (cardGame.DebugInfo.LastFunction != breakInfo.Funcdef) { Console.WriteLine("step into happened " + cardGame.DebugInfo.LastFunction + " != " + breakInfo.Funcdef); } break; case StepType.Out: if (cardGame.DebugInfo.LastFunction != breakInfo.Funcdef) { Console.WriteLine("step over/out skipped " + cardGame.DebugInfo.LastFunction + " != " + breakInfo.Funcdef); return; } Console.WriteLine("step over/out okay"); break; case StepType.Over: if (cardGame.DebugInfo.LastFunction != breakInfo.Funcdef) { Console.WriteLine("step over skipped " + cardGame.DebugInfo.LastFunction + " != " + breakInfo.Funcdef); if (!wasLastBreakLast) { Console.WriteLine("wasnt last line, gonna skip "); return; } if (wasLastIndexBreakLast != breakInfo.Funcdef) { Console.WriteLine("wasnt idk line, gonna skip "); return; } Console.WriteLine("was last line, gonna continue"); } Console.WriteLine("step over/out okay"); break; case StepType.Lookup: Console.WriteLine("Lookup"); break; default: Console.WriteLine("idk step " + cardGame.DebugInfo.StepThrough); break; } cardGame.DebugInfo.LastFunction = breakInfo.Funcdef; var yieldObject = new FiberYieldResponse(FiberYieldResponseType.Break, breakInfo.Line, ""); while (true) { Console.WriteLine("breaking"); var answ = Fiber<FiberYieldResponse>.Yield(yieldObject); if (answ == null) { //continue return; } if (answ.VariableLookup != null) { object lookup; try { lookup = varLookup(answ.VariableLookup); } catch (Exception e) { lookup = e.Message; } yieldObject = new FiberYieldResponse(FiberYieldResponseType.VariableLookup, breakInfo.Line, Json.Stringify(lookup)); continue; } break; } } } }