Beispiel #1
0
        public IHttpActionResult PostCARDS(CARDS cARDS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CARDS.Add(cARDS);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (CARDSExists(cARDS.Doc))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = cARDS.Doc }, cARDS));
        }
    CARDS ParseJson(string selectedJSON)     //string array from StringStorage players card deck
    {
        CARDS CardStats = new CARDS();

        JsonUtility.FromJsonOverwrite(selectedJSON, CardStats);         //parse the jsontable to values for the variables in class CARDS
        return(CardStats);
    }
Beispiel #3
0
    public void BeginMuligan(int numberOfCards)
    {
        gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
        decks       = gameManager.Decks;
        json        = GameObject.Find("GameManager").GetComponent <ParseFromJSON>();

        numCards = numberOfCards;

        for (int i = 0; i < numberOfCards; i++)
        {
            int whatCard = Random.Range(0, decks[0].Count);

            c = json.loadFile(decks[0][whatCard]);

            if (c.card_type.ToLower() == "spell")
            {
                mulCards.Add(Instantiate(spellCard, transform, false) as GameObject);
                mulCards[i].transform.GetChild(0).GetComponent <SpellCardGenerator>().GenerateCard(c);
            }
            else
            {
                mulCards.Add(Instantiate(creatureCard, transform, false) as GameObject);
                mulCards[i].transform.GetChild(0).GetComponent <CardGenerator>().GenerateCard(c);
            }

            muliganSelectors[i] = Instantiate(muliganSelctor, mulCards[i].transform, false);
            muliganSelectors[i].transform.localPosition             = new Vector3(0, 0, 0);
            muliganSelectors[i].GetComponent <MuliganSelector>().id = i;
            mulCards[i].GetComponent <Draggable>().enabled          = false;
            decks[0].RemoveAt(whatCard);
        }

        AiMul();
    }
Beispiel #4
0
    public void CardDraw(int playerIndex)
    {
        if (gameManager.Decks[playerIndex].Count > 0)
        {
            json = GameObject.Find("GameManager").GetComponent <ParseFromJSON>();
            int whatCard = Random.Range(0, gameManager.Decks[playerIndex].Count);
            c = json.loadFile(gameManager.Decks[playerIndex][whatCard]);
            GameObject g;

            //if (c.card_type.ToLower() == "spell")
            //{
            //	g = (Instantiate(spellCard, playerHands[playerIndex].transform, false) as GameObject);
            //	g.transform.GetChild(0).GetComponent<SpellCardGenerator>().GenerateCard(c);
            //}
            //else
            {
                g = (Instantiate(creatureCard, playerHands[playerIndex].transform, false) as GameObject);
                g.transform.GetChild(0).GetComponent <CardGenerator>().GenerateCard(c);
            }

            if (playerIndex == 1)
            {
                g.BroadcastMessage("DisableTexts");
                g.transform.GetChild(0).GetComponent <CardClass>().OwnerId = 1;
                g.transform.GetComponent <Draggable>().enabled             = false;
            }

            gameManager.Decks[playerIndex].RemoveAt(whatCard);
        }

        else
        {
            OverDraw(playerIndex);
        }
    }
Beispiel #5
0
        public IHttpActionResult PutCARDS(decimal id, CARDS cARDS)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cARDS.Doc)
            {
                return(BadRequest());
            }

            db.Entry(cARDS).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CARDSExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #6
0
        public IHttpActionResult PutCARDS(Peticion pet)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            CARDS cARDS = decard.CARDS.Find(pet.Doc);

            System.Diagnostics.Debug.WriteLine("aaaaaaaaaaa", cARDS);
            System.Diagnostics.Debug.WriteLine(cARDS.Pass.ToString());
            System.Diagnostics.Debug.WriteLine(pet.Pass.ToString());
            System.Diagnostics.Debug.WriteLine(cARDS.Avaliable);
            System.Diagnostics.Debug.WriteLine(pet.Value);
            System.Diagnostics.Debug.WriteLine(cARDS.Pass.Trim(' ').Equals(pet.Pass.Trim(' ')));
            System.Diagnostics.Debug.WriteLine(cARDS.Avaliable >= pet.Value);

            Respuesta response = new Respuesta();

            if (cARDS.Pass.Trim(' ').Equals(pet.Pass.Trim(' ')) && cARDS.Avaliable >= pet.Value)
            {
                cARDS.Avaliable           = cARDS.Avaliable - pet.Value;
                decard.Entry(cARDS).State = EntityState.Modified;

                System.Diagnostics.Debug.WriteLine("aaaaaaaaaaa");
                DateTime  thisDay = DateTime.Today;
                Historial history = new Historial();
                history.Id  = 0;
                history.Doc = pet.Doc;
                System.Diagnostics.Debug.WriteLine("aaaaaaaaaaa");
                history.Fecha = thisDay.ToString();
                history.Pass  = pet.Pass.Trim(' ');
                System.Diagnostics.Debug.WriteLine("aaaaaaaaaaa");
                history.Value = pet.Value;
                System.Diagnostics.Debug.WriteLine("aaaaaaaaaaa1");

                db.Historial.Add(history);
                db.SaveChanges();
                System.Diagnostics.Debug.WriteLine("aaaaaaaaaaa2");

                response.NumAprobacion   = history.Id;
                response.FechaAprobacion = thisDay.ToString();
                System.Diagnostics.Debug.WriteLine("aaaaaaaaaaa3");
            }
            else
            {
                response.NumAprobacion = 0;
                DateTime thisDayMal = DateTime.Today;
                response.FechaAprobacion = thisDayMal.ToString();
                return(Ok(response));
            }


            decard.SaveChanges();



            return(Ok(response));
        }
Beispiel #7
0
        public IHttpActionResult GetCARDS(decimal id)
        {
            CARDS cARDS = db.CARDS.Find(id);

            if (cARDS == null)
            {
                return(NotFound());
            }

            return(Ok(cARDS));
        }
Beispiel #8
0
        public IHttpActionResult DeleteCARDS(decimal id)
        {
            CARDS cARDS = db.CARDS.Find(id);

            if (cARDS == null)
            {
                return(NotFound());
            }

            db.CARDS.Remove(cARDS);
            db.SaveChanges();

            return(Ok(cARDS));
        }
    public void GenerateCard(CARDS card)
    {
        c = card;

        spell = GetComponent <Spell>();
        GetComponent <CardClass>().Card = card;

        pictureAssetName = "Cards/Textures/" + c.picture_name;
        portrait.GetComponent <MeshRenderer>().material.mainTexture = Resources.Load(pictureAssetName) as Texture;

        manaTextObj.GetComponent <Text>().text     = c.mana.ToString();
        cardTextObj.GetComponent <Text>().text     = c.description;
        cardNameTextObj.GetComponent <Text>().text = c.card_name;

        gemHolderObj.SetActive(true);
        gemObj.SetActive(true);

        gemObj.GetComponent <MeshRenderer>().material.mainTexture = Resources.Load("Cards/Textures/Gems/gem_" + c.rarity) as Texture;

        cardFaceObj.GetComponent <MeshRenderer>().material.mainTexture = Resources.Load("Cards/Textures/Cardfronts/card_spell_" + c.class_name) as Texture;
        transform.GetComponent <CardClass>().CardName = cardNameTextObj.GetComponent <Text>().text;
    }
Beispiel #10
0
    void ParseCardToJson() //values from another  file
    {
        Debug.Log("JOSN TEEST ");
        //jsontable for cards
        CARDS cardDeck = new CARDS();

        cardDeck.card_name    = "Lord Jaraxxus";
        cardDeck.mana         = 10;
        cardDeck.health       = 15;
        cardDeck.description  = "Burning legion lel";
        cardDeck.damage       = 5;
        cardDeck.card_type    = "spell";
        cardDeck.rarity       = "legendary";
        cardDeck.picture_name = "jaraxxus";
        cardDeck.class_name   = "warlock";
        cardDeck.race         = "Demon";
        cardDeck.abilities_cr = new int[] { 1, 3, 4 };
        cardDeck.abilities_sp = new int[] {};
        cardDeck.flavor_text  = "Le burning lord of the legion xdd";
        cardDeck.day_or_night = "none";
        string json2 = JsonUtility.ToJson(cardDeck);

        Debug.Log(json2);  //print table
    }
Beispiel #11
0
    void AiMul()
    {
        for (int i = 0; i < 3 + (4 - numCards); i++)
        {
            int whatAiCard = Random.Range(0, decks[1].Count);

            c = json.loadFile(decks[1][whatAiCard]);
            aiCards.Add(c);
            print(c.card_name);
            decks[1].RemoveAt(whatAiCard);
        }

        foreach (CARDS card in aiCards)
        {
            if (card.mana > 4)
            {
                aiMul.Add(card);
            }
        }

        if (aiMul.Count > 0)
        {
            foreach (CARDS mul in aiMul)
            {
                decks[1].Add(mul.card_id);
                aiCards.Remove(mul);
            }

            foreach (CARDS mul in aiMul)
            {
                int whatAiCard = Random.Range(0, decks[1].Count);
                aiCards.Add(json.loadFile(decks[1][whatAiCard]));
                decks[1].RemoveAt(whatAiCard);
            }
        }
    }
Beispiel #12
0
    public void EndMuligan()
    {
        if (numCards == 4)
        {
            Instantiate(theCoin, playerHand.transform, false);
        }


        if (discardedCards.Count > 0)
        {
            foreach (int discard in discardedCards)
            {
                decks[0].Add(mulCards[discard].transform.GetChild(0).GetComponent <CardClass>().Card.card_id);
            }

            foreach (int discard in discardedCards)
            {
                int whatCard = Random.Range(0, decks[0].Count);
                mulCards[discard].transform.GetChild(0).GetComponent <CardClass>().Card.card_id = json.loadFile(decks[0][whatCard]).card_id;
                decks[0].RemoveAt(whatCard);
            }
        }

        foreach (GameObject g in mulCards)
        {
            cardsToHand.Add(g.transform.transform.GetChild(0).GetComponent <CardClass>().Card.card_id);
        }

        foreach (int card in cardsToHand)
        {
            c = json.loadFile(card);
            GameObject g;

            if (c.card_type.ToLower() == "spell")
            {
                g = Instantiate(spellCard, playerHand.transform, false) as GameObject;
                g.GetComponent <SpellCardGenerator>().GenerateCard(c);
            }
            else
            {
                g = Instantiate(creatureCard, playerHand.transform, false) as GameObject;
                g.transform.GetChild(0).GetComponent <CardGenerator>().GenerateCard(c);
            }
        }

        foreach (CARDS aiCard in aiCards)
        {
            GameObject g;

            if (c.card_type.ToLower() == "spell")
            {
                g = Instantiate(spellCard, aiHand.transform, false) as GameObject;
                g.GetComponent <SpellCardGenerator>().GenerateCard(aiCard);
            }
            else
            {
                g = Instantiate(creatureCard, aiHand.transform, false) as GameObject;
                g.transform.GetChild(0).GetComponent <CardGenerator>().GenerateCard(aiCard);
            }

            g.BroadcastMessage("DisableTexts");
            g.transform.GetChild(0).GetComponent <CardClass>().OwnerId = 1;
            g.transform.GetComponent <Draggable>().enabled             = false;
        }

        tauntButton.SetActive(true);

        Destroy(gameObject);
    }
 public void GenerateCard(CARDS cardd)
 {
     card = cardd;
     GenerateCard();
 }
 public void GenerateCard(int cardId)
 {
     card = GameObject.Find("GameManager").GetComponent <ParseFromJSON>().loadFile(cardId);
     GenerateCard();
 }
Beispiel #15
0
    public void CalculateAIBid(Card auctionCard)
    {
        /*To prevent players from catching on to AI's lower point for useless cards, we will track all bets made below 50% of
         * total cash, and remember the percentge, adjusting ours accordingly*/
        GoneCards.Add(auctionCard);
        float avgBetPercentage = 0;
        float bottomCap        = PlayerPrefs.GetFloat("bottomCap");

        for (int i = 0; i < WinningBidPercentage.Count; ++i)
        {
            if (WinningBidPercentage [i] < 0.5)
            {
                avgBetPercentage += WinningBidPercentage [i];
            }
        }
        avgBetPercentage /= WinningBidPercentage.FindAll(a => a < 0.5).Count;
        if (WinningBidPercentage.FindAll(a => a < 0.5).Count > 3)
        {
            if (avgBetPercentage > bottomCap)
            {
                bottomCap += 0.05f;
                PlayerPrefs.SetFloat("bottomCap", bottomCap);
            }
            if (avgBetPercentage < bottomCap)
            {
                bottomCap -= 0.05f;
                PlayerPrefs.SetFloat("bottomCap", bottomCap);
            }
        }

        /*Strategy 1 : Calculate the Value of the current card using a weighted vector system that increases semi exponentially to
         * factor in the difficulty in moving up a level in the later stages. We then find the power value using this vector system
         * and normalize it using total power. This gives us a raw value of the card we can then adjust according to aggresion,
         * bluffing and so on.*/
        this.evaluateHand();

        /*Strategy 2 : If the card will allow me to increase the ranking of my hand, pay 70% of current cash.
         *      If it will increase the value of my hand but keep the ranking same  ie go from pair 4's to pair 9's
         *       then pay 50% of current cash. Otherwise, only bid 10% of current cash.*/
        System.Random rndm          = new System.Random();
        int           current_rank  = CombinationRank;
        int           new_rank      = 0;
        int           new_score     = 0;
        int           current_score = CombinationValue;
        //This will tell wether the player will bluff now or not
        bool bluffNow = (rndm.Next(1, 10) <= 5 ? true : false);
        //This will tell wether the player will make a protective play or not
        bool protectNow = (rndm.Next(1, 10) <= 5 ? true : false);

        //This will calculate the value of the current card
        CARDS.Add(auctionCard);
        this.evaluateHand();
        new_rank  = CombinationRank;
        new_score = CombinationValue;
        float rankVal = Aggression / 10;

        //See if this card will improve our hand, then we adjust the improvement to approximate the chances of winning
        if (current_rank > CombinationRank)
        {
            rankVal += (float)(current_rank - CombinationRank);
            rankVal /= 10;
            rankVal += 0.40f;
        }
        else if ((current_rank == CombinationRank) && (current_score > CombinationValue))
        {
            rankVal += 0.3f;
        }
        else
        {
            this.evaluateHand(GoneCards);
            if (current_rank < CombinationRank && protectNow)
            {
                rankVal += 0.4f;
            }
        }
        this.evaluateHand();
        //Create a bluff, this card cannot help at all, but 10% of the time, the program will act like its an important card.
        if (bluffNow)
        {
            BidValue = (int)(Math.Max(rankVal, Bluff / 10) * cash);
        }
        else
        {
            BidValue = (int)(Math.Max(rankVal, bottomCap) * cash);
        }
        if (BidValue >= (int)(0.9 * Cash))
        {
            BidValue = (int)(0.9 * Cash);
        }
        CARDS.Remove(auctionCard);
    }