예제 #1
0
        public async Task <bool> RetSpilAsync(Spil retSpil)
        {
            if (await AuthenticateUser())
            {
                try
                {
                    await App.mobileServiceClient.InvokeApiAsync("Spil", JToken.FromObject(retSpil), HttpMethod.Put, null);
                }
                catch (MobileServiceInvalidOperationException ex)
                {
                    if (ex.Response.StatusCode == System.Net.HttpStatusCode.Unauthorized)
                    {
                        App.passwordVault.Remove(App.passwordCredentials);
                        await AuthenticateUser();

                        await App.mobileServiceClient.InvokeApiAsync("Spil", JToken.FromObject(retSpil), HttpMethod.Put, null);
                    }
                }
                catch (Exception ex)
                {
                    string mess = ex.ToString();
                }
            }
            else
            {
                MessageDialog dlg = new MessageDialog("Fejl ved authentication!");
                await dlg.ShowAsync();
            }
            return(true);
        }
예제 #2
0
        public List <Move> IspitajObicno(Spil spp, Karta talon) //CheckBasic
        {
            List <Move> potezi = new List <Move>();

            for (int i = 0; i < spp.Karte.Count(); i++)
            {
                if (spp.Karte[i].Broj.CompareTo(talon.Broj) == 0 || spp.Karte[i].Boja == talon.Boja)
                {
                    List <Move> ispitajJ = IspitajJ(spp.Karte[i]);
                    if (ispitajJ.Count() > 0)
                    {
                        foreach (Move m in ispitajJ)
                        {
                            potezi.Add(m);
                        }
                    }
                    else
                    {
                        List <Move> ispitaj8a = new List <Move>();
                        ispitaj8a = Ispitaj8A(spp.Karte[i], spp, ispitaj8a, talon);
                        if (ispitaj8a.Count > 0)
                        {
                            foreach (Move m in ispitaj8a)
                            {
                                potezi.Add(m);
                            }
                        }
                    }
                }
            }
            return(potezi);
        }
예제 #3
0
        public async Task Gem()
        {
            if (App.Spil == null)
            {
                var spil = new Spil();
                spil.Makker = Makker;
                spil.Stik   = Stik;
                spil.Melder = Melder;
                BeregnMeldingFraIndtastning(spil, Melding, Skæve);
                await _whistApi.OpretSpilAsync(spil);

                NavigationService.Navigate(typeof(RundePage), App.RundeH);
            }
            else
            {
                var spil = App.Spil;
                spil.Makker = Makker;
                spil.Stik   = Stik;
                spil.Melder = Melder;
                BeregnMeldingFraIndtastning(spil, Melding, Skæve);
                await _whistApi.RetSpilAsync(spil);

                NavigationService.Navigate(typeof(RundePage), App.RundeH);
            }
        }
 static void Init()
 {
     spil = GameObject.FindObjectOfType<Spil> ();
     SpilEditorConfig window = (SpilEditorConfig)EditorWindow.GetWindow (typeof(SpilEditorConfig));
     window.autoRepaintOnSceneChange = true;
     window.titleContent.text = "Configuration";
     window.Show ();
 }
예제 #5
0
        public bool DeleteSpil(int?Id)
        {
            Spil spil = ctx.Spil.Find(Id);

            ctx.Spil.Remove(spil);
            ctx.SaveChanges();
            return(true);
        }
예제 #6
0
        public static void Error(string message)
        {
            Spil spil = GameObject.FindObjectOfType <Spil>();

            if (spil != null && spil.EditorLogging)
            {
                Debug.LogError(message);
            }
        }
        /// <summary>
        /// This method is marked as internal and should not be exposed to developers.
        /// The Spil Unity SDK is not packaged as a seperate assembly yet so this method is currently visible, this will be fixed in the future.
        /// Internal method names start with a lower case so you can easily recognise and avoid them.
        /// </summary>
        internal override void SpilInit(bool withPrivacyPolicy)
        {
#if UNITY_ANDROID
            Spil spil = GameObject.FindObjectOfType <Spil>();
            CallNativeMethod("init", new object[] { withPrivacyPolicy }, true);
            RegisterDevice(spil.ProjectId);
            RequestPackages();
#endif
        }
예제 #8
0
 public int NadjiUSpilu(Spil spil, Karta k) //Find in the deck
 {
     for (int i = 0; i < spil.Karte.Count(); i++)
     {
         if (spil.Karte[i].Broj.CompareTo(k.Broj) == 0 && spil.Karte[i].Boja == k.Boja)
         {
             return(i);
         }
     }
     return(-1);
 }
예제 #9
0
 private void BeregnMeldingFraIndtastning(Spil spil, int Melding, int Skæve)
 {
     if (Skæve > 0 && Melding > 1)
     {
         Melding += Skæve * 10;
     }
     int[] point = WhistCalc.BeregnPoint(spil.Melder, Melding, spil.Stik, spil.Makker);
     spil.Point1 = point[0];
     spil.Point2 = point[1];
     spil.Point3 = point[2];
     spil.Point4 = point[3];
 }
예제 #10
0
    static void Init()
    {
        spil = GameObject.FindObjectOfType <Spil>();
        SpilEditorConfig window = (SpilEditorConfig)EditorWindow.GetWindow(typeof(SpilEditorConfig));

        window.autoRepaintOnSceneChange = true;
        window.titleContent.text        = "Configuration";
        window.Show();

        androidGameVersion = PlayerSettings.bundleVersion;
        androidPackageName = GetAndroidPackageName();
        iosGameVersion     = PlayerSettings.bundleVersion;
        iosBundelId        = GetIOSBundleId();
    }
예제 #11
0
        public List <Move> Ispitaj8A(Karta k, Spil spil, List <Move> ispitaj8a, Karta talon) //Check for 8
        {
            talon = k;
            if (k.Broj.CompareTo("8") == 0 || k.Broj.CompareTo("A") == 0)
            {
                ispitaj8a.Add(new Move(TipPoteza.BacaKartu, k.Boja, k));
                if (NadjiUSpilu(spil, k) > -1)
                {
                    spil.Karte.RemoveAt(NadjiUSpilu(spil, k));
                }

                List <Move> pom = IspitajObicno(spil, talon);
                foreach (Move p in pom)
                {
                    ispitaj8a.Add(p);
                }
            }

            return(ispitaj8a);
        }
예제 #12
0
        public void reset()
        {
            numOfRemCard = 52;
            Suits        = new List <Karta> [4];
            Numbers      = new List <Karta> [13];

            for (int i = 0; i < 4; i++)
            {
                Suits[i] = new List <Karta>();
            }
            for (int i = 0; i < 13; i++)
            {
                Numbers[i] = new List <Karta>();
            }
            Spil karte = new Spil();

            foreach (Karta karta in karte.Karte)
            {
                Suits[(int)karta.Boja - 1].Add(karta);
                Numbers[brojToNumber(karta.Broj) - 1].Add(karta);
            }
        }
예제 #13
0
        public IEnumerator SendCoroutine()
        {
            Spil spil = GameObject.FindObjectOfType <Spil>();

            platform = EditorUserBuildSettings.activeBuildTarget.ToString().Trim().ToLower();

#if UNITY_5_6_OR_NEWER
            bundleIdentifier = PlayerSettings.applicationIdentifier;
#elif UNITY_5_3_OR_NEWER
            bundleIdentifier = PlayerSettings.bundleIdentifier;
                        #endif

            AddDefaultParameters();

            WWWForm requestForm = new WWWForm();
            requestForm.AddField("name", eventName);
            requestForm.AddField("data", data.ToString());
            requestForm.AddField("customData", !customData.IsNull ? customData.Print() : "{}");


            var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            var time  = (long)(DateTime.Now.ToUniversalTime() - epoch).TotalMilliseconds;

            requestForm.AddField("ts", time.ToString());
            requestForm.AddField("queued", 0);
            if (Spil.Instance.GetPrivValue() > -1)
            {
                requestForm.AddField("priv", Spil.Instance.GetPrivValue());
            }


            if (spil.EditorDebugMode)
            {
                requestForm.AddField("debugMode", Convert.ToString(spil.EditorDebugMode).ToLower());
            }

            if (SpilUnityEditorImplementation.spilToken != null)
            {
                requestForm.AddField("spilToken", SpilUnityEditorImplementation.spilToken);
            }

            WWW request =
                new WWW(
                    "https://apptracker.spilgames.com/v1/native-events/event/" + platform + "/" + Spil.BundleIdEditor +
                    "/" + eventName, requestForm);
            yield return(request);

            SpilLogging.Log("Sending event: " + "Name: " + eventName + " \nData: " + data + " \nCustom Data: " +
                            customData.Print() + " \nTimestamp: " + time);

            if (request.error != null && !request.error.Equals(""))
            {
                if (Spil.BundleIdEditor == null || Spil.BundleIdEditor.Equals(""))
                {
                    SpilLogging.Error(
                        "Spil Initialize might not have been called! Please make sure you call Spil.Initialize() at app start!");
                }
                else if (request.responseHeaders != null && request.responseHeaders.Count > 0)
                {
                    foreach (KeyValuePair <string, string> entry in request.responseHeaders)
                    {
                        if (entry.Key.Equals("STATUS"))
                        {
                            if (entry.Value.Contains("401"))
                            {
                                SocialLoginManager.ProcessUnauthorizedResponse(request.text);
                                SpilLogging.Error("Unauthorized 401 event! Error: " + request.text);
                            }
                            else
                            {
                                SpilLogging.Error("Error getting data: " + request.error);
                                SpilLogging.Error("Error getting data: " + request.text);
                            }
                        }
                    }
                }
                else
                {
                    SpilLogging.Error("Error getting data: " + request.error);
                    SpilLogging.Error("Error getting data: " + request.text);
                }
            }
            else
            {
                JSONObject serverResponse = new JSONObject(request.text);
                SpilLogging.Log("Data returned: \n" + serverResponse);
                ResponseEvent.Build(serverResponse);
            }
            GameObject.Destroy(this);
        }
예제 #14
0
파일: Engine.cs 프로젝트: CommName/MauMau
        public Engine(int numOfBots)
        {
            deck = new Spil(true);
            if (numOfBots == 0)
            {
                player1 = new PlayerUser(false);
                player2 = new PlayerUser(false);
            }
            else if (numOfBots == 1)
            {
                Random random = new Random();
                if (random.Next() % 2 == 0)
                {
                    player1 = new PlayerUser(false);
                    player2 = new PlayerUser(true);
                }
                else
                {
                    player1 = new PlayerUser(true);
                    player2 = new PlayerUser(false);
                }
            }
            else
            if (numOfBots == 2)
            {
                player1 = new PlayerUser(new _16114.Gilgamesh());
                player2 = new PlayerUser(new _16114.Gilgamesh());
            }
            else
            {
                throw new Exception("Neispravan broj igraca");
            }


            player1.nextPlayer     = player2;
            player1.previousPlayer = player2;
            player2.nextPlayer     = player1;
            player2.previousPlayer = player1;


            topCard    = deck.Karte[0];
            cardsPlaid = new List <Karta>();
            deck.Karte.RemoveAt(0);
            //Da ne pocninje partiju sa kaznenim kartama
            if (topCard.Broj == "7" || (topCard.Broj == "2" && topCard.Boja == Boja.Tref))
            {
                int index = 0;
                while (deck.Karte[index].Broj == "7" || (deck.Karte[index].Broj == "2" && deck.Karte[index].Boja == Boja.Tref))
                {
                    index++;
                }
                Karta pom = topCard;
                topCard           = deck.Karte[index];
                deck.Karte[index] = pom;
            }
            cardsPlaid.Add(topCard);
            suit         = Boja.Unknown;
            penalty      = 0;
            drewCard     = false;
            playerChange = true;

            //Dealibg cards
            player1.SetRuka(deck.Karte.GetRange(0, 6));
            deck.Karte.RemoveRange(0, 6);
            player2.SetRuka(deck.Karte.GetRange(0, 6));
            deck.Karte.RemoveRange(0, 6);
            player1.Bacenekarte(cardsPlaid, Boja.Unknown, 6);
            player2.Bacenekarte(cardsPlaid, Boja.Unknown, 6);
            cardsPlaid.Clear();
            current = player1;
        }
예제 #15
0
 public bool PutSpil(Spil retSpil)
 {
     ctx.Entry(retSpil).State = System.Data.Entity.EntityState.Modified;
     ctx.SaveChanges();
     return(true);
 }
예제 #16
0
 public bool PostSpil(Spil nytSpil)
 {
     ctx.Spil.Add(nytSpil);
     ctx.SaveChanges();
     return(true);
 }