public DateWithoutFormatRuleTest()
        {
            const string contract = "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"title\": \"teste 2\",\n    \"version\": \"1.0\"\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/path-one\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                 \"zero\" : {\n                  \"type\" : \"string\",\n                  \"example\": \"2020-07-09\"\n                },\n                \"one\" : {\n                  \"type\" : \"string\",\n                  \"example\": \"2020-07-08\"\n                },\n                \"two\" : {\n                  \"type\" : \"string\",\n                  \"example\": \"2017-07-21T17:32:28Z\"\n                },\n                \"three\" : {\n                  \"type\" : \"string\",\n                  \"example\": \"2019/09/11\"\n                },\n                \"four\" : {\n                  \"type\" : \"string\",\n                  \"example\": \"13:29\"\n                },\n                \"five\" : {\n                  \"type\" : \"string\",\n                  \"example\": \"04/03/1998\"\n                },\n                 \"six\" : {\n                  \"type\" : \"string\",\n                  \"example\": \"2017-07-21\",\n                  \"format\": \"date\"\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/path-two\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"seven\" : {\n                      \"type\" : \"string\",\n                      \"example\": \"6\"\n                    },\n                    \"eight\" : {\n                      \"type\" : \"string\",\n                      \"example\": \"A77\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>
            {
                new Supression
                {
                    RuleName = ruleName,
                    Target   = "Path='/path-one',Operation='get',ResponseCode='200',Parameter='zero'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                NestingDepth = new NestingDepthConfig()
                {
                    Depth = 5
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();
        }
Beispiel #2
0
        public PathPluralRuleTest()
        {
            const string contract =
                "{\r\n  \"swagger\" : \"2.0\",\r\n  \"info\" : {\r\n    \"version\" : \"v1\",\r\n    \"title\" : \"Swagger Test\",\r\n  },\r\n  \"consumes\" : [ \"application/json\" ],\r\n  \"produces\" : [ \"application/json\" ],\r\n  \"paths\" : {\r\n    \"/path-one\" : {\r\n      \"get\" : {\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"Will not hit the Rule because there are not data envelope\",\r\n            \"schema\" : {\r\n              \"type\" : \"object\",\r\n              \"properties\" : {\r\n                \"noDataEnvelope\" : {\r\n                  \"type\" : \"object\",\r\n                  \"properties\" : {\r\n                    \"propertyOne\" : {\r\n                      \"type\" : \"string\"\r\n                    }\r\n                  }\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/paths-two\" : {\r\n      \"get\" : {\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"Will hit the rule: plural, data, no array.\",\r\n            \"schema\" : {\r\n              \"type\" : \"object\",\r\n              \"properties\" : {\r\n                \"data\" : {\r\n                  \"type\" : \"object\",\r\n                  \"properties\" : {\r\n                    \"propertyOne\" : {\r\n                      \"type\" : \"string\"\r\n                    }\r\n                  }\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/path-three\" : {\r\n      \"get\" : {\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"Will not hit the rule: singular\",\r\n            \"schema\" : {\r\n              \"type\" : \"object\",\r\n              \"properties\" : {\r\n                \"data\" : {\r\n                  \"type\" : \"object\",\r\n                  \"properties\" : {\r\n                    \"propertyOne\" : {\r\n                      \"type\" : \"string\"\r\n                    }\r\n                  }\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/path-fours\" : {\r\n      \"get\" : {\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"Will not hit the rule: empty\"\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/path-fives\" : {\r\n      \"get\" : {\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"Will not hit the rule: array ok\",\r\n            \"schema\" : {\r\n              \"type\" : \"object\",\r\n              \"properties\" : {\r\n                \"data\" : {\r\n                  \"type\" : \"array\",\r\n                  \"items\": {\r\n           \"type\" : \"object\",\r\n                    \"properties\" : {\r\n                      \"propertyOne\" : {\r\n                      \"type\" : \"string\"\r\n                      }\r\n                    }\r\n                  }\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/paths-six/{PathSixId}\" : {\r\n      \"get\" : {\r\n        \"parameters\": [ {\r\n          \"in\": \"path\",\r\n          \"name\": \"PathSixId\",\r\n          \"required\": true,\r\n          \"type\": \"string\"\r\n        }],\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"Will not hit the rule: {id}\"\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/paths-seven/{PathSixId}\" : {\r\n      \"get\" : {\r\n        \"parameters\": [ {\r\n          \"in\": \"path\",\r\n          \"name\": \"PathSixId\",\r\n          \"required\": true,\r\n          \"type\": \"string\"\r\n        }],\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"Will not hit the rule: {id}\"\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/health\" : {\r\n      \"get\" : {\r\n        \"responses\" : {\r\n          \"200\" : {\r\n            \"description\" : \"Will not hit the rule, because it is at exceptions.\"\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>
            {
                new Supression {
                    RuleName = ruleName, Target = "Path='/path-one'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                PathPlural = new PathPluralConfig()
                {
                    Exceptions = "health,xpto"
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();

            ruleSettings.Value.PathPlural.Exceptions = "health,xpto";
        }
        public ContentEnvelopeRuleTest()
        {
            const string contract =
                "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"version\" : \"v1\",\n    \"title\" : \"Swagger Test\",\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/path-one\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"noDataEnvelope\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/path-two\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"noDataEnvelope\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/path-three\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/path-four\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"Status 200\"\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            var settings = new RuleSettings()
            {
                ContentEnvelope = new ContentEnvelopeConfig()
                {
                    EnvelopeName = "data"
                }
            };

            ruleSettings = Options.Create(settings);

            supressions = new Supressions(new List <Supression>
            {
                new Supression {
                    RuleName = ruleName, Target = "Path='/path-one',Operation='get',ResponseCode='200'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            cache = new OpenApiDocumentCache();
        }
Beispiel #4
0
        public EmptyExamplesRuleTest()
        {
            const string contract =
                "{\r\n  \"swagger\": \"2.0\",\r\n  \"info\": {\r\n    \"title\": \"teste 2\",\r\n    \"version\": \"1.0\"\r\n  },\r\n  \"consumes\": [\r\n    \"application/json\"\r\n  ],\r\n  \"produces\": [\r\n    \"application/json\"\r\n  ],\r\n  \"paths\": {\r\n    \"/path-one\": {\r\n      \"get\": {\r\n        \"responses\": {\r\n          \"200\": {\r\n            \"description\": \"Status 200\",\r\n            \"schema\": {\r\n              \"type\": \"object\",\r\n              \"properties\": {\r\n                \"data\": {\r\n                  \"type\": \"object\",\r\n                  \"properties\": {\r\n                    \"propertyOne\": {\r\n                      \"type\": \"string\",\r\n                      \"example\": \"An example\"\r\n                    },\r\n                    \"propertyTwo\": {\r\n                      \"type\": \"string\"\r\n                    }\r\n                  }\r\n                },\r\n                \"propertyThree\": {\r\n                  \"type\": \"string\"\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/path-two\": {\r\n      \"get\": {\r\n        \"responses\": {\r\n          \"200\": {\r\n            \"description\": \"Status 200\",\r\n            \"schema\": {\r\n              \"type\": \"object\",\r\n              \"properties\": {\r\n                \"data\": {\r\n                  \"type\": \"object\",\r\n                  \"properties\": {\r\n                    \"propertyFour\": {\r\n                      \"type\": \"string\"\r\n                    }\r\n                  }\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/path-three\": {\r\n      \"get\": {\r\n        \"responses\": {\r\n          \"200\": {\r\n            \"description\": \"Status 200\",\r\n            \"schema\": {\r\n              \"type\": \"object\",\r\n              \"properties\": {\r\n                \"data\": {\r\n                  \"type\": \"object\",\r\n                  \"properties\": {\r\n                    \"propertyOne\": {\r\n                      \"type\": \"string\"\r\n                    },\r\n                    \"propertyTwo\": {\r\n                      \"type\": \"string\"\r\n                    }\r\n                  }\r\n                },\r\n                \"propertyThree\": {\r\n                  \"type\": \"string\"\r\n                }\r\n              }\r\n            },\r\n            \"examples\": {\r\n              \"example-1\": {\r\n                \"data\": {\r\n                  \"propertyOne\": \"An example at schema for propertyOne\",\r\n                  \"propertyTwo\": \"An example at schema for propertyTwo\"\r\n                },\r\n                \"propertyThree\": \"An example at schema for propertyThree\"\r\n              },\r\n              \"example-2\": {\r\n                \"data\": {\r\n                  \"propertyOne\": \"ex2\",\r\n                  \"propertyTwo\": \"ex2\"\r\n                },\r\n                \"propertyThree\": \"ex2\"\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/path-four\": {\r\n      \"get\": {\r\n        \"responses\": {\r\n          \"200\": {\r\n            \"description\": \"Status 200\",\r\n            \"schema\": {\r\n              \"type\": \"object\",\r\n              \"properties\": {\r\n                \"data\": {\r\n                  \"type\": \"array\",\r\n                  \"items\": {\r\n                    \"properties\": {\r\n                      \"propertyOne\": {\r\n                        \"type\": \"string\",\r\n                        \"example\": \"examplePropertyOne\"\r\n                      },\r\n                      \"propertyTwo\": {\r\n                        \"type\": \"string\",\r\n                        \"example\": \"examplePropertyTwo\"\r\n                      }\r\n                    }\r\n                  }\r\n                },\r\n                \"propertyThree\": {\r\n                  \"type\": \"string\",\r\n                  \"example\": \"examplePropertyThree\"\r\n                }\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    },\r\n    \"/path-five\": {\r\n      \"get\": {\r\n        \"responses\": {\r\n          \"200\": {\r\n            \"description\": \"Status 200\",\r\n            \"schema\": {\r\n              \"type\": \"object\",\r\n              \"properties\": {\r\n                \"data\": {\r\n                  \"type\": \"array\",\r\n                  \"items\": {\r\n                  \"properties\": {\r\n                    \"propertyOne\": {\r\n                      \"type\": \"string\"\r\n                    },\r\n                    \"propertyTwo\": {\r\n                      \"type\": \"string\"\r\n                    }\r\n                  }\r\n                  }\r\n                },\r\n                \"propertyThree\": {\r\n                  \"type\": \"string\"\r\n                }\r\n              }\r\n            },\r\n            \"examples\": {\r\n              \"example-1\": {\r\n                \"data\": [{\r\n                  \"propertyOne\": \"An example at schema for propertyOne\",\r\n                  \"propertyTwo\": \"An example at schema for propertyTwo\"\r\n                }],\r\n                \"propertyThree\": \"An example at schema for propertyThree\"\r\n              },\r\n              \"example-2\": {\r\n                \"data\": {\r\n                  \"propertyOne\": \"ex2\",\r\n                  \"propertyTwo\": \"ex2\"\r\n                },\r\n                \"propertyThree\": \"ex2\"\r\n              }\r\n            }\r\n          }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>
            {
                new Supression
                {
                    RuleName = ruleName,
                    Target   = "Path='/path-two',Operation='get',ResponseCode='200'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                NestingDepth = new NestingDepthConfig()
                {
                    Depth = 5
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();
        }
Beispiel #5
0
 public DiceGameSettings(RoundStartSettings roundStartSettings, DiceSettings diceSettings, PlayerSettings playerSettings, RuleSettings ruleSettings)
 {
     _startSettings        = roundStartSettings;
     _diceSettings         = diceSettings;
     _playerPlayerSettings = playerSettings;
     _ruleSettings         = ruleSettings;
 }
        public void CallInterstitial(RuleSettings rulesForNextBoard)
        {
            DebugLog("[ADS] call interstitial");
            adsController.TryShowInterstitial(() =>
            {
                // started
                DebugLog("[ADS] interstitial video started");
                SoundController.Instance.MuteMusic(true);
            }, () =>
            {
                // success
                DebugLog("[ADS] interstitial video success");
                analyticsController.SendAdResult(AdResultType.Watched, AdType.Interstitial, AdSourceType.NotSet);
                StartCoroutine(StartGameHandler(rulesForNextBoard));
                SoundController.Instance.MuteMusic(false);

                adsController.lastInterstitialShownTime = DateTime.Now;
                print($"[ADS] Last interstitial shown time -> {DateTime.Now.ToString()}");

                return;
            }, () =>
            {
                // error
                DebugLog("[ADS] interstitial video error");
                analyticsController.SendAdResult(AdResultType.Error, AdType.Interstitial, AdSourceType.NotSet);
                StartCoroutine(StartGameHandler(rulesForNextBoard));
                SoundController.Instance.MuteMusic(false);
                return;
            });
        }
        public PathWithCrudNamesRuleTest()
        {
            const string contract =
                "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"version\" : \"v1\",\n    \"title\" : \"Swagger Test\",\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/gravar-path-one\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/apagar-path-two\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\": \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>
            {
                new Supression {
                    RuleName = ruleName, Target = "Path='/gravar-path-one'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                PathWithCrudNames = new PathWithCrudNamesConfig()
                {
                    WordsToAvoid = "get,consultar,recuperar,listar,ler,obter,post,salvar,gravar,enviar,postar,path,atualizar,delete,apagar,deletar,remover,excluir"
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();
        }
 public void StartFtueGame(Player player, RuleSettings selectedRuleset)
 {
     if (ShouldPlayFirstFtueGame && int.Parse(selectedRuleset.Id).Equals(1))
     {
         ftueGame_1.StartGame(player, selectedRuleset, this, sessionScript, overlayUISceneActivator);
     }
     else if (ShouldPlaySecondFtueGame && int.Parse(selectedRuleset.Id).Equals(2))
     {
         ftueGame_2.StartGame(player, selectedRuleset, this, sessionScript, overlayUISceneActivator);
     }
     else if (ShouldPlayThirdFtueGame && int.Parse(selectedRuleset.Id).Equals(3))
     {
         ftueGame_3.StartGame(player, selectedRuleset, this, sessionScript, overlayUISceneActivator);
     }
     else if (ShouldPlayFourthFtueGame && int.Parse(selectedRuleset.Id).Equals(4))
     {
         ftueGame_4.StartGame(player, selectedRuleset, this, sessionScript, overlayUISceneActivator);
     }
     else if (ShouldPlayFifthFtueGame && int.Parse(selectedRuleset.Id).Equals(5))
     {
         ftueGame_5.StartGame(player, selectedRuleset, this, sessionScript, overlayUISceneActivator);
     }
     else if (ShouldPlaySixthFtueGame && int.Parse(selectedRuleset.Id).Equals(6))
     {
         ftueGame_6.StartGame(player, selectedRuleset, this, sessionScript, overlayUISceneActivator, ShouldShowHintTip);
     }
 }
        public ArrayOnNoResourceIdEndpointTest()
        {
            const string contract =
                "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"version\" : \"v1\",\n    \"title\" : \"Swagger Test\",\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/path-one\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"It will not hit the Rule because there are no data envelope\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"noDataEnvelope\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/paths-two\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"It will hit the rule: plural, data, no array.\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/path-three\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"It will not hit the rule: singular\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/path-fours\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"It will not hit the rule: empty\"\n          }\n        }\n      }\n    },\n    \"/path-fives\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"It will not hit the rule: array ok\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"array\",\n                  \"items\": {\n \t\t\t\t\t\"type\" : \"object\",\n                    \"properties\" : {\n                      \"propertyOne\" : {\n                    \t\"type\" : \"string\"\n                      }\n                  \t}\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/paths-six/{PathSixId}\" : {\n      \"get\" : {\n        \"parameters\": [ {\n          \"in\": \"path\",\n          \"name\": \"PathSixId\",\n          \"required\": true,\n          \"type\": \"string\"\n        }],\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"It will not hit the rule: {id}\"\n          }\n        }\n      }\n    },\n    \"/paths-seven\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"It will hit the rule: plural, data, no array.\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            var settings = new RuleSettings()
            {
                ArrayOnNoResourceIdEndpoint = new ArrayOnNoResourceIdEndpointConfig()
                {
                    Example = "\"data\": [ { object 1 }, { object n } ]"
                }
            };

            ruleSettings = Options.Create(settings);

            supressions = new Supressions(new List <Supression>
            {
                new Supression {
                    RuleName = ruleName, Target = "Path='/paths-two',Operation='get',ResponseCode='200'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            cache = new OpenApiDocumentCache();
        }
        public PathCaseRuleTest()
        {
            const string contract =
                "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"version\" : \"v1\",\n    \"title\" : \"Swagger Test\",\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/pathOne\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/pathTwo\" : {\n      \"get\" : {\n        \"parameters\" : [{\n            \"in\" : \"query\",\n            \"name\" : \"parameterOne\",\n            \"type\" : \"string\",\n            \"description\" : \"too short\",\n            \"required\" : true\n        }]\n        ,\n        \"responses\" : {\n          \"200\" : {\n            \"description\": \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>
            {
                new Supression {
                    RuleName = ruleName, Target = "Path='/pathOne'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                PathCase = new PathCaseConfig()
                {
                    CaseType = "KebabCase",
                    CaseTypeTolerateNumber = true,
                    Example = "distritos-federais"
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();
        }
Beispiel #11
0
        public VersionFormatRuleTest()
        {
            const string contract = "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"version\" : \"1.2.3\",\n    \"title\" : \"Swagger Test\",\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/path-one\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>());

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                VersionFormat = new VersionFormatConfig()
                {
                    RegexExpectedFormat  = "^(v\\d+)$",
                    HumanReadeableFormat = "'v' + integer version number",
                    Example = "v2"
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();
        }
Beispiel #12
0
        public HealthCheckRuleTest()
        {
            const string contract =
                "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"version\" : \"v1\",\n    \"title\" : \"Swagger Test\",\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/gravar-path-one\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\" : \"\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/apagar-path-two\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\": \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>());

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                HealthCheck = new HealthCheckConfig()
                {
                    Regex = "^(health)$"
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();
        }
        public ValidResponseCodesRuleTest()
        {
            const string contract =
                "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"version\" : \"v1\",\n    \"title\" : \"Swagger Test\",\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/path-one\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"299\" : {\n            \"description\" : \"\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/path-two\" : {\n      \"get\" : {\n        \"parameters\" : [{\n            \"in\" : \"query\",\n            \"name\" : \"parameterOne\",\n            \"type\" : \"string\",\n            \"description\" : \"too short\",\n            \"required\" : true\n        }]\n        ,\n        \"responses\" : {\n          \"418\" : {\n            \"description\": \"Status 418\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"propertyOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>
            {
                new Supression {
                    RuleName = ruleName, Target = "Path='/path-one',Operation='get',ResponseCode='299'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                ValidResponseCodes = new ValidResponseCodesConfig()
                {
                    ValidHttpCodes = "200,201,202,204,206,301,303,304,307,400,401,403,404,405,410,414,422,428,429,500,501,503,504"
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();
        }
        private bool CreateNewLevel(string problemString, int[] targets)
        {
#if UNITY_EDITOR
            RuleSettings newRule = ScriptableObject.CreateInstance <RuleSettings>();
            newRule.Id            = GUID.Generate().ToString();
            newRule.levelData     = problemString;
            newRule.targetIndexes = targets;
            newRule.IsFtueGame    = ftueToggle.isOn;
            if (newRule.IsRuleValid())
            {
                string ftuePrefix = newRule.IsFtueGame ? "FTUE" : "";
                AssetDatabase.CreateAsset(newRule, $"Assets/Speedoku/Settings/Levels/Level{ftuePrefix}{newRule.Id}.asset");
                if (!newRule.IsFtueGame)
                {
                    GlobalSettings settings = (GlobalSettings)AssetDatabase.LoadAssetAtPath("Assets/Speedoku/Settings/GlobalSettings.asset", typeof(GlobalSettings));
                    settings.RulesList.Add(newRule);
                    EditorUtility.SetDirty(settings);
                }
                AssetDatabase.SaveAssets();
                return(true);
            }
#endif

            return(false);
        }
        public PropertyNamingMatchingPathRuleTest()
        {
            const string contract =
                "{\n  \"swagger\" : \"2.0\",\n  \"info\" : {\n    \"version\" : \"v1\",\n    \"title\" : \"Swagger Test\",\n  },\n  \"consumes\" : [ \"application/json\" ],\n  \"produces\" : [ \"application/json\" ],\n  \"paths\" : {\n    \"/path-one\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"addressPathOne\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    },\n    \"/path-two\" : {\n      \"get\" : {\n        \"responses\" : {\n          \"200\" : {\n            \"description\": \"Status 200\",\n            \"schema\" : {\n              \"type\" : \"object\",\n              \"properties\" : {\n                \"data\" : {\n                  \"type\" : \"object\",\n                  \"properties\" : {\n                    \"addressPathTwo\" : {\n                      \"type\" : \"string\"\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}";

            openApiContract = new OpenApiStringReader().Read(contract, out OpenApiDiagnostic _);

            supressions = new Supressions(new List <Supression>
            {
                new Supression
                {
                    RuleName = ruleName,
                    Target   = "Path='/path-one',Operation='get',ResponseCode='200',PropertyFull='data.addressPathOne'"
                }
            });

            supressionEntireRule = new Supressions(
                new List <Supression> {
                new Supression {
                    RuleName = ruleName, Target = "*"
                }
            });

            var settings = new RuleSettings()
            {
                NestingDepth = new NestingDepthConfig()
                {
                    Depth = 20
                }
            };

            ruleSettings = Options.Create(settings);

            cache = new OpenApiDocumentCache();
        }
Beispiel #16
0
        public GameplayScript LoadBoard(RuleSettings ruleSettings)
        {
            //print($"[GAME] Loading board - ruleset name: {ruleSettings.PuzzleNameKey}");

            player = SceneActivationBehaviour <GameLogicActivator> .Instance.GameController.Player;

            for (int i = 0; i < boardPlaceHolder.transform.childCount; i++)
            {
                Destroy(boardPlaceHolder.transform.GetChild(i));
            }

            backgroundImage.sprite = ruleSettings.BoardBackgroundImage;
            FreshBoard             = Instantiate(boardPrefab, boardPlaceHolder.transform);

            boardCreationScript = FreshBoard.GetComponent <BoardCreationScript>();
            boardGameplayScript = FreshBoard.GetComponent <GameplayScript>();

            boardCreationScript.InitiateBoard(ruleSettings);
            bonusBarUIActivator.InitiateBonusBar(ruleSettings, boardGameplayScript);

            Vector3 boardScale = boardPlaceHolder.transform.localScale;

            SceneActivationBehaviour <PostGameSceneActivator> .Instance.SetBoardHolderScale(boardScale);

            TrySpawnQuixel();

            return(boardGameplayScript);
        }
        //ReorderableList locationProperty;

        private void OnEnable()
        {
            //coinsProperty = serializedObject.FindProperty("Coins");
            //boundaryProperty = serializedObject.FindProperty("locationBoundaries");
            rulesProperty = new ReorderableList(serializedObject, serializedObject.FindProperty("RulesList"), true, true, true, true);
            //locationProperty = new ReorderableList(serializedObject, serializedObject.FindProperty("LocationSettings"), true, true, true, true);

            rulesProperty.drawHeaderCallback = (Rect rect) =>
            {
                rulesProperty.serializedProperty.isExpanded = EditorGUI.ToggleLeft(rect, rulesProperty.serializedProperty.displayName, rulesProperty.serializedProperty.isExpanded, EditorStyles.boldLabel);
            };

            rulesProperty.onRemoveCallback = (ReorderableList l) => {
                if (EditorUtility.DisplayDialog("Warning!",
                                                "Are you sure you want to delete this rule?", "Yes", "No"))
                {
                    ReorderableList.defaultBehaviours.DoRemoveButton(l);
                    ReorderableList.defaultBehaviours.DoRemoveButton(l); //Double because single only deletes the rule not hte array placement
                }
            };
            rulesProperty.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                var element = rulesProperty.serializedProperty.GetArrayElementAtIndex(index);
                if (element.objectReferenceValue != null)
                {
                    RuleSettings rule = (RuleSettings)element.objectReferenceValue;
                    rect.y += 4;

                    EditorGUI.LabelField(new Rect(rect.x + 60, rect.y, 150, EditorGUIUtility.singleLineHeight), $"Diff: {rule.difficultyRating} \t FTUE: { rule.IsFtueGame}");
                    EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, new GUIContent($"Rule {index}: ")); //new Rect(rect.x, rect.y, 250, EditorGUIUtility.singleLineHeight)
                }
            };

            //locationProperty.drawHeaderCallback = (Rect rect) =>
            //{
            //    locationProperty.serializedProperty.isExpanded = EditorGUI.ToggleLeft(rect, locationProperty.serializedProperty.displayName, locationProperty.serializedProperty.isExpanded, EditorStyles.boldLabel);
            //};

            //locationProperty.onRemoveCallback = (ReorderableList l) => {
            //    if (EditorUtility.DisplayDialog("Warning!",
            //        "Are you sure you want to delete this location?", "Yes", "No"))
            //    {
            //        ReorderableList.defaultBehaviours.DoRemoveButton(l);
            //        ReorderableList.defaultBehaviours.DoRemoveButton(l); //Double because single only deletes the rule not hte array placement
            //    }
            //};
            //locationProperty.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
            //{
            //    var element = locationProperty.serializedProperty.GetArrayElementAtIndex(index);
            //    if (element.objectReferenceValue != null)
            //    {
            //        LocationSetting location = (LocationSetting)element.objectReferenceValue;
            //        rect.y += 4;

            //        EditorGUI.LabelField(new Rect(rect.x + 30, rect.y, 200, EditorGUIUtility.singleLineHeight), $"Name: {location.locationName}");
            //        EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight), element, new GUIContent($"{index}:")); //new Rect(rect.x, rect.y, 500, EditorGUIUtility.singleLineHeight)
            //    }
            //};
        }
        public void ShowNoCoinsPopup(RuleSettings ruleSettings, int currentStarRecord)
        {
            string localisedMessage = GameConstants.MainGame.FeatureMessages.ReplayError;
            string message          = string.Concat((localisedMessage.Substring(0, localisedMessage.IndexOf('#'))), levelReplayCost, (localisedMessage.Substring(localisedMessage.IndexOf('#') + 1)));

            noCoinsPopupDetails.PopulateInformation(ruleSettings.PuzzleIcon, LocalisationSystem.GetLocalisedValue(ruleSettings.PuzzleNameKey), message, currentStarRecord, replayGoldLevel);
            NoCoinsPopupPanel.SetActive(true);
        }
        private void GameQuitHandler(MainGameData gameData)
        {
            print($"[SESSION] GameQuit");
            IsInGame = false;

            //Update gameplay count even though quit for ad purposes
            GameEndedHandler();
            SessionQuit?.Invoke(gameData);
            currentSessionRuleset = null;
        }
Beispiel #20
0
        public void InitiateBoard(RuleSettings ruleSettings)
        {
            boardDebugText.text = SceneActivationBehaviour <GameLogicActivator> .Instance.GameController.DisplayDebugText ? ruleSettings.Id + ", " + LocalisationSystem.GetLocalisedValue(ruleSettings.PuzzleNameKey) : "";

            puzzleNameText.text = LocalisationSystem.GetLocalisedValue(ruleSettings.PuzzleNameKey);

            levelString = ruleSettings.LevelString;

            activeCells.Clear();
            gridLabelManager.ClearValues();

            CellColourDictionary.Clear();
            CellColourDictionary.Add("x".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_x);
            CellColourDictionary.Add("0".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_0);
            CellColourDictionary.Add("1".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_1);
            CellColourDictionary.Add("2".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_2);
            CellColourDictionary.Add("3".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_3);
            CellColourDictionary.Add("4".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_4);
            CellColourDictionary.Add("5".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_5);
            CellColourDictionary.Add("6".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_6);
            CellColourDictionary.Add("7".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_7);
            CellColourDictionary.Add("8".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_8);
            CellColourDictionary.Add("9".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_9);
            CellColourDictionary.Add("a".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_a);
            CellColourDictionary.Add("b".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_b);
            CellColourDictionary.Add("c".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_c);
            CellColourDictionary.Add("d".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_d);
            CellColourDictionary.Add("e".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_e);
            CellColourDictionary.Add("f".ToUpperInvariant(), GameConstants.CellColours.PaletteColour_f);

            if (levelString != null)
            {
                gridSize = ((int)Mathf.Sqrt(levelString.Length));
                gridLineScript.SetGridLines(gridSize);
            }

            if (editableGridSize)
            {
                ShowAllGrid();
                ShowValidPictureCells();
            }

            ClearTargetCells?.Invoke();

            GatherActiveGridCells();

            toolbarUIActivator = SceneActivationBehaviour <ToolbarUIActivator> .Instance;
            toolbarUIActivator.PassBoardCreationScript(this);

            //SetModeToPencil();

            SceneActivationBehaviour <ToolbarUIActivator> .Instance.ToggleToPaint();

            ftueHighlightAnimator.gameObject.SetActive(false);
        }
Beispiel #21
0
        public void StartGame(Player player,
                              RuleSettings selectedRuleset,
                              FtueController ftueController,
                              SessionScript sessionScript,
                              OverlayUISceneActivator overlayUISceneActivator)
        {
            print("[FTUE] Fifth ftue game started ");

            InterfaceController.Instance.Show(GameWindow.OverlayUIScene);
            InterfaceController.Instance.Hide(GameWindow.MainMenu);

            SceneActivationBehaviour <TopBarUIActivator> .Instance.SetButtons(false);

            GameplayScript      gameplay            = sessionScript.CreateGameAndStart(player, selectedRuleset);
            BoardCreationScript boardCreationScript = gameplay.GetComponent <BoardCreationScript>();

            InterfaceController.Instance.Show(GameWindow.BonusBarUI);
            SceneActivationBehaviour <BonusBarUIActivator> .Instance.ShowDim(true);

            InterfaceController.Instance.Hide(GameWindow.ToolbarUI);

            boardCreationScript.BlockAllCells();

            overlayUISceneActivator.ShowFtueGameplayMessage(GameConstants.Ftue.FourthGame.FtueMessages.Instructions4_1, true, true, 0, true);

            ftueController.SendFtueProgress("Game4StartStarBar_27");

            overlayUISceneActivator.SubscribeForFullScreenTap(() =>
            {
                SceneActivationBehaviour <BonusBarUIActivator> .Instance.ShowDim(false);

                ftueController.SendFtueProgress("ReadyStart_28");
                overlayUISceneActivator.ShowFtueGameplayMessage(GameConstants.Ftue.FourthGame.FtueMessages.Instructions4_2, true, true, 0, true);

                overlayUISceneActivator.SubscribeForFullScreenTap(() =>
                {
                    ftueController.SendFtueProgress("StartGame4_29");

                    overlayUISceneActivator.HideFtueMessages();

                    overlayUISceneActivator.ftueMessagesPerStage = 0;
                    gameplay.StartDelayedSession();

                    boardCreationScript.UnblockAllCells();

                    gameplay.OnPuzzleSolved += gameData =>
                    {
                        int i = int.Parse(gameData.Ruleset.Id);
                        ftueController.ProceedToGameOverAward(player, i);

                        ftueController.SendFtueProgress("Game4Complete_30");
                    };
                });
            });
        }
 public PreprocessedRule()
 {
     Impersonate   = false;
     Settings      = new RuleSettings();
     Language      = RuleLanguage.Unknown;
     References    = new List <string>();
     Imports       = new List <string>();
     Events        = new List <string>();
     FirstCodeLine = 0;
     RuleCode      = new List <string>();
 }
Beispiel #23
0
        /// <summary>
        /// Initialize the gameplay
        /// </summary>
        public void Configure(RuleSettings rules, GameType gameType, int playerFilm, bool replay = false)
        {
            gameData = new MainGameData
            {
                Ruleset             = rules,
                Replay              = replay,
                GameType            = gameType,
                PlayerFilmRemaining = playerFilm
            };

            isPaused = true;
        }
        private void GameQuitHandler(MainGameData gameData)
        {
            if (gameData != null)
            {
                IsInGame = false;

                // clean up gameboard
                SceneActivationBehaviour <BoardUIActivator> .Instance.DestroyBoard();

                SessionFinished?.Invoke(gameData);
                currentSessionRuleset = null;
            }
        }
        public void ShowGoldPopup(RuleSettings levelRules, Object goldCard, Sprite cardBackground, Action <bool> coinButtonClicked) //RuleSettings selectedRuleset, Action CoinPurchaseClicked, Action WatchVideoClicked, Action ExitClicked)
        {
            thisLevelRules              = levelRules;
            levelBeingPlayed            = goldCard;
            goldLevelUnlockCost         = SceneActivationBehaviour <GameLogicActivator> .Instance.GameController.GlobalSettings.Coins.GoldLevelUnlockCost;
            coinTextField.text          = $"{goldLevelUnlockCost}";
            coinPurchaseClicked         = coinButtonClicked;
            levelTextField.text         = thisLevelRules.Id;
            levelBackgroundImage.sprite = cardBackground;
            print($"Gold popup for {thisLevelRules.Id}");

            Show();
        }
        public void ResetBoard()
        {
            validationIcon.sprite = null;
            RuleSettings rules = ScriptableObject.CreateInstance <RuleSettings>();

            rules.levelData     = "000000000000000000000000000000000000000000000000000000000000000000000000000000000";
            rules.targetIndexes = new int[] { };
            MainGameData data = new MainGameData
            {
                Ruleset = rules
            };

            gameplay.ConfigureCreator(data);
        }
Beispiel #27
0
        public void PopulateLevelInformation(RuleSettings levelRules, int group, Sprite groupBackground)
        {
            thisLevelRules   = levelRules; // give level rules
            levelNumber.text = thisLevelRules.Id;
            uniqueID         = levelRules.UniqueID;
            puzzleSprite     = levelRules.PuzzleIcon;
            //puzzleIcon.sprite = levelRules.PuzzleIcon;
            gameObject.SetActive(true);

            levelLocale = new Vector2(group, int.Parse(thisLevelRules.Id));

            levelRules.BoardBackgroundImage = groupBackground;

            return;
        }
        private void GameRestartedHandler(MainGameData gameData)
        {
            if (gameData != null)
            {
                IsInGame = false;

                // clean up gameboard
                SceneActivationBehaviour <BoardUIActivator> .Instance.DestroyBoard();

                SessionRestarted?.Invoke(gameData);
                currentSessionRuleset = null;

                StartCoroutine(SceneActivationBehaviour <GameLogicActivator> .Instance.GameController.StartGameHandler(gameData.Ruleset));
            }
        }
        public void ShowOutOfFilmPanel(RuleSettings selectedRuleset, Action CoinPurchaseClicked, Action WatchVideoClicked, Action ExitClicked)
        {
            SoundController.Instance.PlayAudioClip(Settings.Autogenerated.SoundSettingsKey.Filmpopupappear);

            ruleSettings = selectedRuleset;

            coinPurchaseClicked = CoinPurchaseClicked;
            watchVideoClicked   = WatchVideoClicked;
            exitClicked         = ExitClicked;

            outOfFilmPanel.SetActive(true);

            Show();

            coinButton.SetInteractability(SceneActivationBehaviour <GameLogicActivator> .Instance.GameController.Player.Coins >= 100);
        }
Beispiel #30
0
        public void InitGridWithRules(MainGameData gameData, Action <GridAnswer[]> completion)
        {
            rules       = gameData.Ruleset;
            gridSquares = tileContainer.GetComponentsInChildren <GridSquareScript>();
            targets     = new List <GridSquareScript>();
            //allSquares = new int[0];
            currentSelection   = null;
            completionCallback = completion;
            levelTitle.text    = $"LEVEL {gameData.Level}";
            int[] levelData = rules.levelData.Select(x => Int32.Parse(x.ToString())).ToArray();
            print($"Level data count: {levelData.Length}");

            if (levelData.Length == gridSquares.Length)
            {
                for (int i = 0; i < levelData.Length; i++)
                {
                    bool isTarget = rules.targetIndexes.Contains(i);
                    gridSquares[i].SetupGridSquare(i, levelData[i], isTarget, SquareSelected);
                    if (isTarget)
                    {
                        targets.Add(gridSquares[i]);
                    }
                }
            }
            keyboardController.SetKeyboardClickHandler(KeyboardInput);
            keyboardController.SetKeyboardEnabled(false);
            keyboardController.ShowKeyboard();
            if (gameData.answers != null)
            {
                GridAnswer[] errors   = gameData.answers.Where(x => x.correct == false).ToArray();
                GridAnswer[] corrects = gameData.answers.Where(x => x.correct == true).ToArray();
                if (errors.Length > 0)
                {
                    StartCoroutine(ShowPreviousErrors(errors, ShowNextTarget));
                    if (corrects.Length == 0)
                    {
                        return;
                    }
                }
                if (corrects.Length > 0)
                {
                    StartCoroutine(ShowPreviousCorrects(corrects));
                    return;
                }
            }
            ShowNextTarget();
        }
 public void Insert(int index, RuleSettings eventSettings)
 {
 }
 // Methods
 public void Add(RuleSettings ruleSettings)
 {
 }