Exemplo n.º 1
0
        private void BtnCreaDif_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtNomeDif.Text == "")
                {
                    throw new Exception("Inserisci un nome per il tuo personaggio");
                }
                if (cmbRazzaDif.SelectedIndex == -1)
                {
                    throw new Exception("Inserisci una razza per il tuo personaggio");
                }

                int         index = cmbRazzaDif.SelectedIndex;
                Personaggio p     = new Personaggio(txtNomeDif.Text, Razze[index]);

                Personaggi.Add(p);

                lblOutput.Content += "- Difensore creato!            \n";


                //reset
                txtNomeAtt.Text           = "";
                cmbRazzaAtt.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        protected void grdAccount_RowClicked(object sender, GridViewRowClickedEventArgs args)
        {
            try
            {
                errorMessage.Visible = false;
                long accountToHack  = long.Parse(args.Row.Cells[0].Text.Trim());
                long livelloHacking = -1;
                PersonaggiManagerNew charactermanager = new PersonaggiManagerNew(DatabaseContext);
                Personaggio          account          = charactermanager.GetCharacterByNumber(accountToHack);
                if (account.Fazione != rete)
                {
                    return;
                }

                long valoreProtezione = account.LivelloProtezione;
                if (valoreProtezione > livelloHacking)
                {
                    livelloHacking = valoreProtezione;
                }
                hackControl.IdentificatoreElemento = accountToHack;
                hackControl.LivelloHacking         = livelloHacking;
                hackControl.Carica();
                pageViews.SetActiveView(viewHackAccount);
            }
            catch
            {
                pageViews.SetActiveView(viewAccountList);
            }
        }
Exemplo n.º 3
0
        public void OnCrypting(long crypterLevel)
        {
            if (LoggedCharacter != null)
            {
                using (HolonetEntities context = new HolonetEntities())
                {
#warning dovrei salvarmi il codice per ricaricare il personaggio dal context, invece di ricaricarlo dalla sessione. Aggiustare!
                    Personaggio loadedCharacter = (Personaggio)Session["Personaggio"];

                    Personaggio currentCharacter = (from characters in context.Personaggios
                                                    where characters.NumeroPG == loadedCharacter.NumeroPG
                                                    select characters).First();

                    if (crypterLevel >= currentCharacter.LivelloCrittazione)
                    {
                        currentCharacter.LivelloCrittazione = crypterLevel;
                        currentCharacter.UltimaCrittazione  = DateTime.Now;
                        context.SaveChanges();
                    }
                    //int protection = 0;
                    //if (currentCharacter.Hacker.HasValue)
                    //{
                    //    protection += (int)currentCharacter.Hacker;
                    //}
                    //protection += (int)currentCharacter.LivelloCrittazione;
                    //lblLevel.Text = protection.ToString();
                    lblLevel.Text = currentCharacter.Protezione.ToString();
                }
                Page_Load(this, new EventArgs());
            }
        }
Exemplo n.º 4
0
 public bool AddSkillToCharacter(long numeroPg, long cdAbilita, long?numAcquisti, string attitudine, string specifiche)
 {
     try
     {
         AbilitaManager          skillManager = new AbilitaManager(context);
         Personaggio             character    = GetCharacterByNumber(numeroPg);
         DataAccessLayer.Abilita skill        = skillManager.GetSkill(cdAbilita);
         if (character.PossiedeAbilita(cdAbilita))
         {
             if (skill.Multiacquisto == 0)
             {
                 AbilitaPersonaggio newSkill = (from abilitas in character.AbilitaPersonaggios
                                                where abilitas.CdAbilita == cdAbilita
                                                select abilitas).FirstOrDefault();
                 newSkill.NumeroAcquisti = numAcquisti;
             }
         }
         else
         {
             AbilitaPersonaggio newSkill = new AbilitaPersonaggio();
             newSkill.CdAbilita      = cdAbilita;
             newSkill.CdAttitudine   = attitudine;
             newSkill.NumeroAcquisti = numAcquisti;
             newSkill.NumeroPG       = numeroPg;
             newSkill.Specifiche     = specifiche;
             character.AbilitaPersonaggios.Add(newSkill);
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 5
0
        //
        // GET: /Home/

        public ActionResult Index()
        {
            NotizieManager       newsM = new NotizieManager(DatabaseContext);
            PersonaggiManagerNew pgM   = new PersonaggiManagerNew(DatabaseContext);
            NotizieModel         news  = new NotizieModel();
            HomeModel            model = new HomeModel();

            if (User.Identity.Name != null && User.Identity.Name != "")
            {
                Personaggio pg = pgM.GetCharacterByNumber(long.Parse(User.Identity.Name));
                news = newsM.GetActiveNewsInModel((long)pg.Fazione, DateTime.Now);
                switch ((long)pg.Fazione)
                {
                case 0:
                    model.css = "main.css";
                    break;

                case 1:
                case 2:
                case 3:
                    model.css = "main-impero.css";
                    break;
                }
            }
            else
            {
                news = newsM.GetActiveNewsInModel(0, DateTime.Now);
            }
            model.notizie = news;
            return(View(model));
        }
Exemplo n.º 6
0
        protected void TimerTick(object sender, EventArgs e)
        {
            Timer1.Enabled    = false;
            txtRisultato.Text = string.Empty;
            PageViews.SetActiveView(viewRisultato);
            Guid?uniqueCode = null;

            if (!string.IsNullOrWhiteSpace(qrReader.Code))
            {
                uniqueCode = new Guid(qrReader.Code);
            }
            PersonaggiManagerNew manager        = new PersonaggiManagerNew(DatabaseContext);
            Personaggio          characterFound = manager.GetCharacterByGUID(uniqueCode);

            if (characterFound != null)
            {
                if (characterFound.Infeziones.Count == 0)
                {
                    txtRisultato.Text = "Il soggetto risulta essere sano e privo di infezioni";
                }
                else
                {
                    foreach (var Infezione in characterFound.Infeziones)
                    {
                        txtRisultato.Text += Infezione.Nome + ": " + Infezione.Descrizione + "\r\n";
                    }
                }
            }
            else
            {
                txtRisultato.Text = "La sostanza analizzata non è sangue, perlomeno di nessuna specie conosciuta";
            }
        }
Exemplo n.º 7
0
        private void ShowNotizia()
        {
            if (PosizioneLettura < 0)
            {
                PosizioneLettura = 0;
            }
            if (PosizioneLettura >= NewsCollection.Length)
            {
                PosizioneLettura = NewsCollection.Length - 1;
            }
            if (PosizioneLettura < NewsCollection.Length)
            {
                long                 numNotizia       = NewsCollection[PosizioneLettura];
                NotizieManager       newsManager      = new NotizieManager(DatabaseContext);
                PersonaggiManagerNew characterManager = new PersonaggiManagerNew(DatabaseContext);
                //var notizia = (from notizie in DatabaseContext.Notizias
                //                where notizie.NumeroNotizia == numNotizia
                //                select notizie).First();
                Notizia notizia = newsManager.GetSingleNewsItem(numNotizia);
                //var persAutore = (from personaggio in DatabaseContext.Personaggios
                //                    where personaggio.NumeroPG == notizia.Autore
                //                    select personaggio).First();
                Personaggio persAutore = characterManager.GetCharacterByNumber(notizia.Autore.Value);
                lblAutore.Text        = persAutore.Nome;
                lblDataNotizia.Text   = notizia.DataCreazione.ToString();
                lblTitoloNotizia.Text = notizia.Titolo;
                lblTestoNotizia.Text  = notizia.Testo;

                //Ora imposto un'immagine di cronista a caso
                Random randomizer       = new Random();
                int    immagineCronista = randomizer.Next(1, 33);
                facePicture.ImageUrl = "~/Images/Volti/" + immagineCronista.ToString() + ".jpg";
            }
        }
Exemplo n.º 8
0
        //protected void Page_PreInit(object sender, EventArgs e)
        //{
        //    if (Session["Tema"] != null)
        //    {
        //        Page.Theme = Session["Tema"].ToString();
        //    }
        //    else
        //    {
        //        Page.Theme = "TemaBlu";
        //    }
        //}

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (LoggedCharacter != null)
                {
                    Personaggio character = (Personaggio)Session["Personaggio"];
                    IQueryable <AbilitaPersonaggio> ricerca;
                    int CanUse = 0;
                    using (HolonetEntities context = new HolonetEntities())
                    {
                        ricerca = (from abilita in context.AbilitaPersonaggios
                                   where abilita.NumeroPG == character.NumeroPG
                                   where abilita.CdAbilita == 2
                                   select abilita);
                        CanUse = ricerca.Count();
                    }
                    if (CanUse <= 0)
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                    else
                    {
                        Timer1.Interval = 30000;
                    }
                }
            }
        }
Exemplo n.º 9
0
        private void LoadData()
        {
            using (context = CreateDatabaseContext())
            {
                PersonaggiManagerNew     manager     = new PersonaggiManagerNew(context);
                Personaggio              character   = manager.GetCharacterByNumber(numeroPg);
                List <Attitudine>        cmbSource   = new List <Attitudine>();
                IEnumerable <Attitudine> skillgroups = character.Attitudines;
                foreach (var lista in skillgroups)
                {
                    cmbSource.Add(lista);
                }
                AbilitaManager           skillManager = new AbilitaManager(context);
                IEnumerable <Attitudine> expansionGroups;
                if (character.Tipo == 0)
                {
                    expansionGroups = skillManager.GetSkillGroupFromType(DataAccessLayer.Enum.TipoAttitudine.Innesti);
                }
                else
                {
                    expansionGroups = skillManager.GetSkillGroupFromType(DataAccessLayer.Enum.TipoAttitudine.InnestiDroide);
                }
                foreach (var lista in expansionGroups)
                {
                    cmbSource.Add(lista);
                }
                cmbAttitudine.ValueMember   = "CdAttitudine";
                cmbAttitudine.DisplayMember = "Nome";
                cmbAttitudine.DataSource    = cmbSource;

                freePoints         = manager.GetFreeSkillpoints(numeroPg);
                txtFreePoints.Text = freePoints.ToString();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Attacco, metodo utilizzato sia per attacco Mostro-Eroe che per Eroe-Mostro
        /// </summary>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <returns>true se vince p1, false se vince p2</returns>
        private static bool Attacco(Personaggio p1, Personaggio p2)
        {
            Console.ForegroundColor = ConsoleColor.DarkCyan;
            if (p1 is Eroe)
            {
                Console.WriteLine("Turno del tuo eroe " + p1.Nome);
            }
            else
            {
                Console.WriteLine("Turno del mostro " + p1.Nome);
            }

            Console.WriteLine(p1.Nome + " ha inflitto con " + p1.Arma.Nome + " " + p1.Arma.PuntiDanno + " punti vita a " + p2.Nome + " su " + p2.PuntiVita);

            p2.PuntiVita -= p1.Arma.PuntiDanno;
            Console.WriteLine(p2.Nome + " rimane con " + p2.PuntiVita + " punti vita\n");

            Console.ForegroundColor = ConsoleColor.Cyan;

            if (p2.PuntiVita <= 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            try
            {
                Uomo        u1 = new Uomo();
                Troll       t1 = new Troll();
                Personaggio p1 = new Personaggio("Alessio", u1);
                Personaggio p2 = new Personaggio("Mostro", t1);

                Console.WriteLine($"Il personaggio n.1 è {p1.Nome} e sta attaccando il personaggio n.2 {p2.Nome}");

                Console.WriteLine($"{p1.Attacca(p2)}");

                Console.WriteLine("La battaglia si è conclusa, ecco il resoconto dei personaggi:");

                Console.WriteLine(p1.ToString());
                Console.WriteLine(p2.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }
Exemplo n.º 12
0
        //protected void Page_PreInit(object sender, EventArgs e)
        //{
        //    if (Session["Tema"] != null)
        //    {
        //        Page.Theme = Session["Tema"].ToString();
        //    }
        //    else
        //    {
        //        Page.Theme = "TemaBlu";
        //    }
        //}

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (LoggedCharacter != null)
                {
                    Personaggio currentCharacter     = (Personaggio)Session["Personaggio"];
                    Dictionary <long, string> elenco = new Dictionary <long, string>();
                    using (HolonetEntities context = new HolonetEntities())
                    {
                        var elencoRubrica = (from nominativi in context.Rubricas
                                             where nominativi.NumeroPG == currentCharacter.NumeroPG
                                             select nominativi);

                        foreach (var item in elencoRubrica)
                        {
                            elenco.Add(item.NumeroSalvato, item.NomeVisualizzato);
                        }
                    }
                    cmbNomiSalvati.DataValueField = "Key";
                    cmbNomiSalvati.DataTextField  = "Value";
                    cmbNomiSalvati.DataSource     = elenco;
                    cmbNomiSalvati.DataBind();
                }
            }
        }
Exemplo n.º 13
0
        protected void lblTitolo_Click(object sender, EventArgs e)
        {
            PostaInArrivo elemento = null;

            using (HolonetEntities context = new HolonetEntities())
            {
                //Personaggio personaggioAttuale = (Personaggio)Session["Personaggio"];
                Personaggio personaggioAttuale = refCharacter;
                elemento = (from messaggio in context.PostaInArrivoes
                            where messaggio.NumeroMissione == NumeroMissione
                            where messaggio.NumeroPG == personaggioAttuale.NumeroPG
                            select messaggio).First();
                if (elemento != null)
                {
                    elemento.Letta = true;

                    if (!elemento.MissioneReference.IsLoaded)
                    {
                        elemento.MissioneReference.Load();
                        if (!elemento.Missione.PersonaggioReference.IsLoaded)
                        {
                            elemento.Missione.PersonaggioReference.Load();
                        }
                    }
                    context.SaveChanges();
                }
            }
            lblStatoLettura.Text = "Sì";
            ((IMessaggi)this.Page).MessaggioVisualizzato = elemento.Missione;
            ((IMessaggi)this.Page).IsInUscita            = false;
            ((IMessaggi)this.Page).MostraMessaggio();
        }
Exemplo n.º 14
0
        private void CaricaMessaggiInUscita()
        {
            listaMessaggiInviati.refCharacter = (Personaggio)Session["Personaggio"];
            listaMessaggiRicevuti.Visible     = false;
            listaMessaggiInviati.Visible      = true;

            Personaggio          character = (Personaggio)Session["Personaggio"];
            List <PostaInUscita> elenco;

            using (HolonetEntities context = new HolonetEntities())
            {
                var messaggiInUscita = (from messages in context.PostaInUscitas
                                        where messages.NumeroPG == character.NumeroPG
                                        where messages.Cancellata == false
                                        select messages).OrderByDescending(mexs => mexs.NumeroMissione);
                foreach (var messaggio in messaggiInUscita)
                {
                    if (!messaggio.MissioneReference.IsLoaded)
                    {
                        messaggio.MissioneReference.Load();
                    }
                }
                elenco = messaggiInUscita.ToList();
            }
            panMessage.Visible    = false;
            panCancellato.Visible = false;
            panSalvato.Visible    = false;

            //Passo l'elenco dei messaggi al controllo che creerà la lista visibile, e invoco il databind esplicito
            listaMessaggiInviati.Messaggi = elenco;
            listaMessaggiInviati.Carica();
        }
Exemplo n.º 15
0
 private void grdAbilita_SelectionChanged(object sender, EventArgs e)
 {
     txtSpecifiche.Text = null;
     if (grdAbilita.SelectedRows.Count > 0)
     {
         txtSpecifiche.Enabled = true;
         long cdAbilita = (long)grdAbilita.SelectedRows[0].Cells["CdAbilita"].Value;
         using (context = CreateDatabaseContext())
         {
             AbilitaManager          skillmanager = new AbilitaManager(context);
             PersonaggiManagerNew    manager      = new PersonaggiManagerNew(context);
             Personaggio             character    = manager.GetCharacterByNumber(numeroPg);
             DataAccessLayer.Abilita skill        = skillmanager.GetSkill(cdAbilita);
             bool isBought = false;
             long minimum  = 1;
             if (character.PossiedeAbilita(cdAbilita))
             {
                 isBought = true;
                 AbilitaPersonaggio skillBought = (from comprate in character.AbilitaPersonaggios
                                                   where comprate.CdAbilita == cdAbilita
                                                   select comprate).FirstOrDefault();
                 if (skillBought.NumeroAcquisti.HasValue)
                 {
                     minimum = skillBought.NumeroAcquisti.Value;
                 }
             }
             numVolte.Minimum = minimum;
             if (skill.Costo > freePoints)
             {
                 btnSalva.Enabled = false;
             }
             else
             {
                 if (skill.Multiacquisto == 0)
                 {
                     if (isBought)
                     {
                         btnSalva.Enabled = false;
                     }
                     else
                     {
                         btnSalva.Enabled = true;
                     }
                 }
                 else
                 {
                     numVolte.Enabled = true;
                     numVolte.Maximum = minimum + (skill.Costo / freePoints);
                     btnSalva.Enabled = true;
                 }
             }
         }
     }
     else
     {
         txtSpecifiche.Enabled = false;
         btnSalva.Enabled      = false;
     }
 }
Exemplo n.º 16
0
        /// <summary>
        /// Viene eseguito quando viene modificato il testo presente nel textbox dei destinatari
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void txtDestinatari_TextChanged(object sender, EventArgs e)
        {
            string[] destinparts = txtDestinatari.Text.Split(';');
            if (destinparts.Length > 0)
            {
                PersonaggiManagerNew characterManager = new PersonaggiManagerNew(DatabaseContext);
                txtDestinatari.Text = string.Empty;

                for (int i = 0; i < destinparts.Length; i++)
                {
                    try
                    {
                        //Qui dentro controllo se è stato aggiunto un NUMERO nella lista
                        long   numPg      = long.Parse(destinparts[i]);
                        string nameToShow = characterManager.GetCharacterNameByNumber(numPg);
                        destinparts[i] = nameToShow;
                        if (!string.IsNullOrWhiteSpace(nameToShow))
                        {
                            hidReceivers.Value  += numPg + ";";
                            txtDestinatari.Text += nameToShow + "; ";
                        }
                    }
                    catch
                    {
                        if (!string.IsNullOrWhiteSpace(destinparts[i]))
                        {
                            //long? verifyContact = characterManager.GetCharacterNumberByName(destinparts[i]);
                            //if (verifyContact != null)
                            //{
                            //    txtDestinatari.Text += destinparts[i].Trim() + "; ";
                            //}
                            Personaggio verifyContact = characterManager.GetCharacterByName(destinparts[i]);
                            if (verifyContact != null)
                            {
                                if (!hidReceivers.Value.Split(';').Contains(verifyContact.NumeroPG.ToString()))
                                {
                                    hidReceivers.Value += verifyContact.NumeroPG + ";";
                                }
                                txtDestinatari.Text += verifyContact.Nome + "; ";
                            }
                        }
                    }
                }
                //Ora controllo se sono stati ELIMINATI dei nomi, e quindi se devo toglierli dall'hiddenfield
                string[]    numPgs           = hidReceivers.Value.Split(';');
                List <long> contactsRemained = characterManager.GetCharacterNumbersByNames(txtDestinatari.Text.Split(';')).ToList();
                hidReceivers.Value = string.Empty;
                for (int i = 0; i < numPgs.Length; i++)
                {
                    if (!string.IsNullOrWhiteSpace(numPgs[i]) && contactsRemained.Contains(long.Parse(numPgs[i])))
                    {
                        hidReceivers.Value += numPgs[i].Trim() + ";";
                    }
                }
            }
        }
Exemplo n.º 17
0
        protected void btnInvia_Click(object sender, EventArgs e)
        {
            string elencoDestinatari = txtDestinatari.Text.Trim();

            string[] arrayDestinatari = elencoDestinatari.Split(',');

            List <long> numeriDestinatari = new List <long>();

            foreach (string item in arrayDestinatari)
            {
                try
                {
                    long num = long.Parse(item);
                    numeriDestinatari.Add(num);
                }
                catch
                {
                }
            }
            Personaggio currentCharacter = (Personaggio)Session["Personaggio"];

            using (HolonetEntities context = new HolonetEntities())
            {
                long lastMission = (from missioni in context.Missiones
                                    select missioni.NumeroMissione).Max();

                Missione newMessage = new Missione();
                newMessage.NumeroMissione = lastMission + 1;
                newMessage.Attiva         = 1;
                newMessage.Mandante       = currentCharacter.NumeroPG;
                newMessage.Testo          = txtTesto.Text.Replace("\n", "<br />");
                newMessage.Titolo         = txtOggetto.Text.Trim();

                //Livello di crittazione
                newMessage.LivelloCrittazione = Crypted;

                //Per il mittente
                newMessage.PostaInUscitas.Add(new PostaInUscita()
                {
                    NumeroPG = currentCharacter.NumeroPG, Cancellata = false, Letta = false
                });
                //per i destinatari
                foreach (long dest in numeriDestinatari)
                {
                    newMessage.PostaInArrivoes.Add(new PostaInArrivo()
                    {
                        NumeroPG = dest, Cancellata = false, Letta = false
                    });
                }
                context.AddToMissiones(newMessage);
                context.SaveChanges();
            }
            panSendMessage.Visible = false;
            CaricaMessaggiInUscita();
        }
Exemplo n.º 18
0
        private void caricaMessaggiInUscita()
        {
            Personaggio     currentCharacter = this.LoggedCharacter;
            MessaggiManager manager          = new MessaggiManager(DatabaseContext);
            var             OutgoingMessages = manager.GetOutgoingMessagesByCharacter(currentCharacter.NumeroPG);

            grdMessaggi.DataSource = OutgoingMessages;
            grdMessaggi.DataBind();
            lblPageTitle.Text = "Posta in Uscita";
            PageViews.SetActiveView(viewMessageList);
        }
Exemplo n.º 19
0
        public ActionResult Index(HomeModel model)
        {
            PersonaggiManagerNew pgM = new PersonaggiManagerNew(DatabaseContext);
            Personaggio          pg  = pgM.GetCharacterByNumber(long.Parse(model.logon.username));

            if (pg.PasswordHolonet == model.logon.password)
            {
                FormsAuthentication.SetAuthCookie(pg.NumeroPG.ToString(), false);
            }
            return(RedirectToAction("Index", "Home"));
        }
Exemplo n.º 20
0
        private void carica()
        {
            txtNome.Text   = string.Empty;
            txtNumero.Text = string.Empty;
            Personaggio    currentCharacter = this.LoggedCharacter;
            RubricaManager namesManager     = new RubricaManager(DatabaseContext);
            var            myRubrica        = namesManager.GetContactsByCharacter(currentCharacter.NumeroPG);

            grdPeople.DataSource = myRubrica;
            grdPeople.DataBind();
        }
Exemplo n.º 21
0
 public void SceltaArma(List <Arma> armi, Personaggio p)
 {
     Console.WriteLine("Armi disponibili: ");
     foreach (var item in armi)
     {
         if (item.ClasseID == p.ClasseID)
         {
             Console.WriteLine(item.Nome);
         }
     }
 }
Exemplo n.º 22
0
        void qrReader_OnCodeDecoded(object sender, EventArgs e)
        {
            //Tenere a mente: questo sistema di login si basa sul riconoscimento di UN codice recuperato da un QR Code.
            //Quindi non occorre confrontare password o che altro, basta recuperare il personaggio associato a quel codice, e verificare
            //che appartenga alla fazione corretta.
            string myCode = qrReader.Code;             //fase 1: prendo il codice letto dal plugin

            if (!string.IsNullOrEmpty(myCode))
            {
                Guid uniqueCode;
                try
                {
                    uniqueCode = new Guid(myCode);
                }
                catch
                {
                    lblErrorMessage.Text = "Cartellino non valido";                     //Se il codice è un codice ad cazzum, non un GUID, è ovviamente un QR Code sbagliato
                    return;
                }
                PersonaggiManagerNew manager         = new PersonaggiManagerNew(this.DatabaseContext);
                Personaggio          loggedCharacter = manager.GetCharacterByGUID(uniqueCode);        //Cerco nel database un PG associato a quel GUID
                if (loggedCharacter == null)
                {
                    lblErrorMessage.Text = "Cartellino non di login";                     //Se non ho PG associati a quel GUID, non è un cartellino di login. Forse un medicinale o droga o oggetto.
                    return;
                }
                string rete = Session["Rete"].ToString();                 //recupero il codice della rete a cui ci si sta loggando
                if (string.IsNullOrWhiteSpace(rete))
                {
                    rete = "0";
                }
                int numeroRete = int.Parse(rete.Trim());
                if (numeroRete == 0 || loggedCharacter.Fazione == numeroRete)                 //il login è valido se la rete è 0 (Holonet blu), o se il PG appartiene alla fazione dell'holonet specifica (1 = repubblica, 2 = impero, 3 = federazione)
                {
                    HttpCookie cookie = Context.Request.Cookies["Personaggio"];               //popolo il cookie col suo numero PG
                    if (cookie != null)
                    {
                        cookie.Value = loggedCharacter.NumeroPG.ToString();
                    }
                    else
                    {
                        Context.Response.Cookies.Add(new HttpCookie("Personaggio", loggedCharacter.NumeroPG.ToString()));
                    }
                    Session["Personaggio"] = loggedCharacter;
                    Response.Redirect("~/Default.aspx"); //pagina di default con redirect al menu iniziale
                }
                else                                     //Login non valido: non è l'Holonet blu, il personaggio esiste ma non fa parte della fazione.
                {
                    Session["Personaggio"] = null;
                    lblErrorMessage.Text   = "Utente non autorizzato all'accesso";
                }
            }
        }
Exemplo n.º 23
0
 protected void btnSalva_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtNumero.Text) && !string.IsNullOrWhiteSpace(txtNome.Text))
     {
         Personaggio    currentCharacter = this.LoggedCharacter;
         RubricaManager namesManager     = new RubricaManager(DatabaseContext);
         long           contactNumber    = long.Parse(txtNumero.Text.Trim());
         namesManager.AddNewContact(currentCharacter.NumeroPG, contactNumber, txtNome.Text.Trim());
         DatabaseContext.SaveChanges();
     }
     carica();
 }
Exemplo n.º 24
0
 private void LoadSkills()
 {
     txtAbilita.Text = null;
     using (databaseContext = CreateDatabaseContext())
     {
         PersonaggiManagerNew manager   = new PersonaggiManagerNew(databaseContext);
         Personaggio          character = manager.GetCharacterByNumber(numeroPg.Value);
         foreach (var attitudine in character.Attitudines)
         {
             txtAbilita.Text += attitudine.Nome + ":\r\n";
             var theseSkills = from abilitaComprate in character.AbilitaPersonaggios
                               where abilitaComprate.CdAttitudine == attitudine.CdAttitudine
                               select new { Nome = abilitaComprate.Abilita.Nome, Volte = abilitaComprate.NumeroAcquisti, Specifiche = abilitaComprate.Specifiche };
             foreach (var item in theseSkills)
             {
                 txtAbilita.Text += item.Nome + (item.Volte.HasValue ? "x" + item.Volte.Value : null);
                 if (!string.IsNullOrWhiteSpace(item.Specifiche))
                 {
                     txtAbilita.Text += " [" + item.Specifiche + "]";
                 }
                 txtAbilita.Text += "\r\n";
             }
             txtAbilita.Text += "\r\n";
         }
         TipoAttitudine tipoInnesti = TipoAttitudine.Innesti;
         if (character.Tipo == 1)
         {
             tipoInnesti = TipoAttitudine.InnestiDroide;
         }
         //Inserimento abilità degli innesti
         var innesti = from abilitacomprate in character.AbilitaPersonaggios
                       where abilitacomprate.Attitudine.TipoAttitudine == tipoInnesti
                       select new { Nome = abilitacomprate.Abilita.Nome, Volte = abilitacomprate.NumeroAcquisti, Specifiche = abilitacomprate.Specifiche };
         if (innesti.Count() > 0)
         {
             txtAbilita.Text += "ABILITA' AGGIUNTIVE (INNESTI O POTENZIAMENTI):\r\n";
             foreach (var item in innesti)
             {
                 txtAbilita.Text += item.Nome + (item.Volte.HasValue ? "x" + item.Volte.Value : null);
                 if (!string.IsNullOrWhiteSpace(item.Specifiche))
                 {
                     txtAbilita.Text += " [" + item.Specifiche + "]";
                 }
                 txtAbilita.Text += "\r\n";
             }
             txtAbilita.Text += "\r\n";
         }
     }
 }
Exemplo n.º 25
0
 private void grdNotizie_SelectionChanged(object sender, EventArgs e)
 {
     if (grdNotizie.SelectedRows.Count == 1)
     {
         long numeroMissione = (long)grdNotizie.SelectedRows[0].Cells["NumeroNotizia"].Value;
         using (databaseContext = CreateDatabaseContext())
         {
             NotizieManager       manager     = new NotizieManager(databaseContext);
             PersonaggiManagerNew charManager = new PersonaggiManagerNew(databaseContext);
             Notizia     singleNew            = manager.GetSingleNewsItem(numeroMissione);
             Personaggio autore = charManager.GetCharacterByNumber(singleNew.Autore.Value);
             txtTesto.Text  = "AUTORE: " + autore.Nome + "\r\n \r\n";
             txtTesto.Text += singleNew.Testo.Replace("<br />", "\r\n");
         }
     }
 }
Exemplo n.º 26
0
 protected void btnSalva_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtNumero.Text) && !string.IsNullOrWhiteSpace(txtNome.Text))
     {
         Personaggio currentCharacter = (Personaggio)Session["Personaggio"];
         using (HolonetEntities context = new HolonetEntities())
         {
             DataAccessLayer.Rubrica elemento = new DataAccessLayer.Rubrica();
             elemento.NumeroPG         = currentCharacter.NumeroPG;
             elemento.NumeroSalvato    = long.Parse(txtNumero.Text.Trim());
             elemento.NomeVisualizzato = txtNome.Text.Trim();
             context.AddToRubricas(elemento);
             context.SaveChanges();
         }
     }
     carica();
 }
Exemplo n.º 27
0
        public long GetFreeSkillpoints(long numeroPg)
        {
            Personaggio    character    = GetCharacterByNumber(numeroPg);
            long           total        = character.Punti;
            AbilitaManager skillManager = new AbilitaManager(context);

            foreach (AbilitaPersonaggio skill in character.AbilitaPersonaggios)
            {
                DataAccessLayer.Abilita possessedSkill = skillManager.GetSkill(skill.CdAbilita);
                long costo = possessedSkill.Costo;
                if (possessedSkill.Multiacquisto == 1 && skill.NumeroAcquisti.HasValue)
                {
                    costo *= skill.NumeroAcquisti.Value;
                }
                total -= costo;
            }
            return(total);
        }
Exemplo n.º 28
0
        protected void btnInvia_Click(object sender, EventArgs e)
        {
            Personaggio character = (Personaggio)Session["Personaggio"];

            using (HolonetEntities context = new HolonetEntities())
            {
                MessaggioSalvato message = new MessaggioSalvato();
                message.NumeroPG           = character.NumeroPG;
                message.LivelloCrittazione = Crypted;
                message.Contenuto          = txtTesto.Text.Replace("\n", "<br/>");
                message.Provenienza        = "SAVEDFILE";
                message.Titolo             = txtOggetto.Text.Trim();
                context.AddToMessaggioSalvatoes(message);
                context.SaveChanges();
            }
            panWriteFile.Visible = false;
            Crypted = 0;
            CaricaElencoFiles();
        }
Exemplo n.º 29
0
 public bool UpdateCharacterSubscriptionsAndPX(long numeroPG, long cdEvento, bool pagato, DateTime dataPagamento, bool partecipato, long PX)
 {
     try
     {
         var query = from iscrizioni in context.EventoGiorniPersonaggios
                     where iscrizioni.NumeroPg == numeroPG &&
                     iscrizioni.CdEvento == cdEvento
                     select iscrizioni;
         bool assegnaPX = false;
         foreach (var iscrizione in query)
         {
             if (!iscrizione.Pagato && pagato)
             {
                 iscrizione.DataPagamento = dataPagamento;
             }
             if (iscrizione.Pagato && !pagato)
             {
                 iscrizione.DataPagamento = null;
             }
             iscrizione.Pagato = pagato;
             if (!iscrizione.Partecipato && partecipato)
             {
                 iscrizione.Partecipato = partecipato;
                 assegnaPX = true;
             }
         }
         if (assegnaPX)
         {
             Personaggio character = (from personaggi in context.Personaggios
                                      where personaggi.NumeroPG == numeroPG
                                      select personaggi).FirstOrDefault();
             if (assegnaPX)
             {
                 character.Punti += PX;
             }
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            try
            {
                Personaggio Tina = new Personaggio("Tina", Uomo.Istanza);
                Personaggio Givo = new Personaggio("Givo", Orco.Istanza);

                Console.WriteLine($"{Tina} attacca {Givo}");
                Console.WriteLine($"{Tina.Attacca(Givo)}\n");

                Console.WriteLine(Tina);
                Console.WriteLine(Givo);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }