Exemplo n.º 1
0
        public void makeDeal()
        {
            responce contract = read <responce>();

            contra.setCouleur((Couleur)contract.couleur);
            contra.setValue(contract.value);
            contra.setPlayerId(id);
        }
Exemplo n.º 2
0
        public int AskCard(ConnectWork link)
        {
            askcontrat str = new askcontrat();
            deck       deck;
            played     pile;
            responce   res = new responce();
            string     saisie;
            bool       turn   = true;
            int        i      = 0;
            int        numval = 0;

            str  = getStruct <askcontrat>(Marshal.SizeOf(str));
            deck = str.deck;
            pile = str.contrats_pile;
            if (str.turn == _ID)
            {
                Console.WriteLine("les cartes déjà jouer sont :");
                for (int j = 0; j < 4; j++)
                {
                    if (pile.value[j] != -1)
                    {
                        Console.WriteLine("la " + j + " em carte est un(e) " + (Type)pile.ids[j] + " de " + (Couleur)pile.couleur[j] + " qui vaut " + pile.value[j]);
                    }
                }
                while (turn == true)
                {
                    Console.WriteLine("Votre deck est composé de :");
                    i = print_deck(deck);
                    Console.WriteLine("veulliez saisir l'index de la carte que vous voulez jouer");
                    saisie = Console.ReadLine();
                    if (saisie != "")
                    {
                        numval = Convert.ToInt32(saisie);
                        if (numval < i && numval >= 0)
                        {
                            turn = false;
                        }
                    }
                }
                res.value   = numval;
                res.couleur = -1;
                byte[] message = link.getBytes <responce>(res);
                link.getNetworkStream().Write(message, 0, message.Length);
            }
            return(0);
        }
Exemplo n.º 3
0
        public unsafe Carte PlayCard(Deck pile, askcontrat askcard)
        {
            askcard.deck = fillDeck(askcard.deck);
            Header h = new Header();

            h.id_command = 3;
            bool     ok       = false;
            responce responce = new responce();

            while (!ok)
            {
                write <Header>(h);
                write <askcontrat>(askcard);
                responce = read <responce>();
                Carte carte = deck.getElem(responce.value);
                ok = isGoodMove(carte, pile);
            }
            return(deck.PutCard(responce.value));
        }
Exemplo n.º 4
0
        //public unsafe struct askcontrat //2 //3
        public int AskContract(ConnectWork link)
        {
            bool     turn     = true;
            int      stronger = 0;
            responce res      = new responce();
            // Console.WriteLine("AskContract");
            played     tmp;
            deck       deck;
            askcontrat str = new askcontrat();
            string     saisie;
            int        numval = 0;

            str = getStruct <askcontrat>(Marshal.SizeOf(str));
            //Console.WriteLine("turn = " + str.turn);
            tmp         = str.contrats_pile;
            deck        = str.deck;
            res.couleur = -1;
            res.value   = -1;
            for (int i = 0; i < 4; i++)
            {
                if (tmp.ids[i] != -1)
                {
                    if (tmp.value[i] > stronger)
                    {
                        stronger = tmp.value[i];
                    }
                    Console.WriteLine("le joueur " + tmp.ids[i] + " a fait un contrat de " + tmp.value[i] + " de la couleur " + (Couleur)tmp.couleur[i]);
                }
            }
            if (str.turn == _ID)
            {
                Console.WriteLine("A vous de proposer un contrat");
                Console.WriteLine("Votre deck est composé de :");
                print_deck(deck);
                while (turn == true)
                {
                    Console.WriteLine("veuillez saisir le montant du contrat (il doit valoir 0 ou être suppérieur au plus haut des contrats, ce dernier vaut : " + stronger);
                    saisie = Console.ReadLine();
                    if (saisie != "")
                    {
                        numval = Convert.ToInt32(saisie);
                        if (numval == 0 || numval > stronger)
                        {
                            turn = false;
                        }
                    }
                }
                res.value = numval;
                turn      = true;
                while (turn == true)
                {
                    Console.WriteLine("veuillez la couleur du contrat: 0 -> carreau, 1 -> trèfle, 2 -> Pick, 3 -> Coeur");
                    saisie = Console.ReadLine();
                    if (saisie != "")
                    {
                        numval = Convert.ToInt32(saisie);
                        if (numval <= 3 && numval >= 0)
                        {
                            turn = false;
                        }
                    }
                }
                res.couleur = numval;
            }
            if (res.couleur != -1 && res.value != -1)
            {
                byte[] message = link.getBytes <responce>(res);
                link.getNetworkStream().Write(message, 0, message.Length);
            }
            return(0);
        }
Exemplo n.º 5
0
        public void AutoEmail() 
        {

            Indication.SafeInvoke(d => d.Text = "Sending Email");
            List<String> partTOemail = new List<String>();
            String json, respJson, emailedJson = null;
            double runningBalance, percentage, threshold, minFund = 0.000;
            Uri strUrl = new Uri(getBaseAddress().ToString() + ("/getInfoPartners"));
            json = sendRequest(strUrl);
            PartnersInfo partnersInfo = JsonConvert.DeserializeObject<PartnersInfo>(json);

            //Getting All accountID 
            foreach (var item in partnersInfo.partnersDetails)
            {
                partTOemail.Add(item.accountID);
            }

            //Checking account ID in every Partner's database
            String accountIDs = JsonConvert.SerializeObject(partTOemail);
            Uri newUrl = new Uri(getBaseAddress().ToString() + "/checkDetails/?accountID=" + accountIDs);
            respJson = sendRequest(newUrl);
            respartBal resPart = JsonConvert.DeserializeObject<respartBal>(respJson);

            //Calculating the threshold for each Partners
            foreach (var select in partnersInfo.partnersDetails)
            {
                foreach (var compare in resPart.partnerBalance)
                {
                    if (select.accountID == compare.accountID)
                    {
                        //Check running balance
                        runningBalance = double.Parse(compare.runningBalance);

                        threshold = double.Parse(select.threshold);
                        percentage = threshold / 100;

                        //Getting the minimum required amount
                        //Minimum Required Amount for Prefund = Amount Loaded x percentage of threshold 
                        minFund = double.Parse(compare.amountLoaded) * percentage;
                        if (runningBalance <= minFund)
                        {
                            //send email to partner
                            Uri isExitAccountId = new Uri(getBaseAddress().ToString() + ("/IfExistinTable/?AccountID=" + select.accountID + "&emailaddress=" + select.email));
                            String strBool = sendRequest(isExitAccountId);
                            if (strBool == "false")
                            {
                                Uri insertTotable = new Uri(getBaseAddress().ToString() + ("/InsertToTable/?AccountID=" + select.accountID + "&accountname=" + select.accountName + "&emailaddress=" + select.email));
                                String isEXIST = sendRequest(insertTotable);
                                responce resp = JsonConvert.DeserializeObject<responce>(isEXIST);
                                log((resp.rescode == "1") ? resp.message + select.accountID : resp.message);
                            }
                            Uri isEmailed = new Uri(getBaseAddress().ToString() + ("/isEmailed/?accountToSend=" + select.accountID));
                            emailedJson = sendRequest(isEmailed);
                            Emailed emailx = JsonConvert.DeserializeObject<Emailed>(emailedJson);
                            if (emailx.rescode == "0")
                            {
                                SendEmail(GetMessageFormat(select.emailcontent, select.accountName, compare.amountLoaded, select.threshold, compare.runningBalance), select.email);
                                Uri updateIsEmailed = new Uri(getBaseAddress().ToString() + ("/upDateTable/?accountID=" + select.accountID));
                                string strUpdate = sendRequest(updateIsEmailed);
                            }
                            log((emailx.rescode == "") ? emailx.message : emailx.message);
                        }
                    }
                }
            }
            log("Success in Checking and Sending of email - " + DateTime.Now.ToString());
        }