Beispiel #1
0
 public Monster_Form(MonsterAttributes currMonAtt, Form1 form)
 {
     InitializeComponent();
     this.CenterToScreen();
     monAtt = currMonAtt;
     SetUpMonsterStats();
     mainForm = form;
 }
Beispiel #2
0
        private void OpenMonsterForm(ListViewItem monsterListView)
        {
            MonsterAttributes completeMon = JsonConvert.DeserializeObject <MonsterAttributes>(File.ReadAllText(@Application.UserAppDataPath + "/Monster_Lists/monsterList" + monsterListView.Index + ".json"));
            Monster_Form      mForm       = new Monster_Form(completeMon, this);

            Console.WriteLine("Count: {0}", completeMon.name);
            mForm.Text = monsterListView.Text + monsterListView.Index;
            mForm.Show();
        }
Beispiel #3
0
 public void SaveNewMonsterStats(string[] newStats)
 {
     foreach (ListViewItem item in listView1.Items)
     {
         if (newStats[0] == item.SubItems[0].Text)
         {
             MonsterAttributes monAtt = JsonConvert.DeserializeObject <MonsterAttributes>(File.ReadAllText(@Application.UserAppDataPath + "/Monster_Lists/monsterList" + item.Index + ".json"));
             monAtt.initiative = int.Parse(newStats[1]);
             monAtt.hp         = int.Parse(newStats[2]);
             monAtt.currHp     = int.Parse(newStats[3]);
             monAtt.ac         = int.Parse(newStats[4]);
             string completeMon = JsonConvert.SerializeObject(monAtt);
             File.WriteAllText(@Application.UserAppDataPath + "/Monster_Lists/monsterList" + item.Index + ".json", completeMon);
             break;
         }
     }
 }
Beispiel #4
0
        public void AssignAttributes(MonsterAttributes monAtt, List <string> myReaderList)
        {
            monAtt.id        = CreateRandomID();
            monAtt.name      = myReaderList[1];
            monAtt.size      = myReaderList[2];
            monAtt.type      = myReaderList[3];
            monAtt.align     = myReaderList[4];
            monAtt.challenge = int.Parse(myReaderList[5]);
            // nothing in column xp = int.Parse(myReaderList[6]);
            monAtt.cr           = double.Parse(myReaderList[7]);
            monAtt.ac           = int.Parse(myReaderList[8]);
            monAtt.hp           = int.Parse(myReaderList[9]);
            monAtt.currHp       = int.Parse(myReaderList[9]);
            monAtt.hitDice      = myReaderList[10];
            monAtt.speeds       = myReaderList[11];
            monAtt.str          = int.Parse(myReaderList[12]);
            monAtt.dex          = int.Parse(myReaderList[13]);
            monAtt.con          = int.Parse(myReaderList[14]);
            monAtt.intt         = int.Parse(myReaderList[15]);
            monAtt.wis          = int.Parse(myReaderList[16]);
            monAtt.cha          = int.Parse(myReaderList[17]);
            monAtt.savingThrows = myReaderList[18];
            monAtt.skills       = myReaderList[19];
            monAtt.wri          = myReaderList[20];
            monAtt.senses       = myReaderList[21];
            monAtt.languages    = myReaderList[22];
            monAtt.additional   = myReaderList[23];
            monAtt.actions      = myReaderList[24];
            monAtt.arctic       = myReaderList[25];
            monAtt.coast        = myReaderList[26];
            monAtt.desert       = myReaderList[27];
            monAtt.forest       = myReaderList[28];
            monAtt.grassland    = myReaderList[29];
            monAtt.hill         = myReaderList[30];
            monAtt.mountain     = myReaderList[31];
            monAtt.swamp        = myReaderList[32];
            monAtt.underdark    = myReaderList[33];
            monAtt.underwater   = myReaderList[34];
            monAtt.urban        = myReaderList[35];
            monAtt.font         = myReaderList[36];
            monAtt.addInfo      = myReaderList[37];
            Random rnd        = new Random();
            int    initiative = (rnd.Next(1, 21) + (int)Math.Floor((double)(monAtt.dex / 2) + -5));

            monAtt.initiative = initiative;
        }
Beispiel #5
0
        private void PopulateViewListInternalDatabase(int chl)
        {
            string conString = "data source=MonsterDB.db;";
            string query     = "SELECT * FROM monster_list WHERE challenge='" + chl + "' ORDER BY RANDOM() LIMIT 1;";

            Console.WriteLine("Getting here");

            SQLiteConnection conDatabase = new SQLiteConnection(conString);
            SQLiteCommand    cmdDatabase = new SQLiteCommand(query, conDatabase);
            SQLiteDataReader myReader;

            Console.WriteLine("Getting here 2");

            try
            {
                int totalXP = int.Parse(textBox10.Text);
                conDatabase.Open();
                myReader = cmdDatabase.ExecuteReader();
                while (myReader.Read())
                {
                    //totalXP += myReader.GetInt32("XP");
                    // add to json file
                    List <string> monsterAttList = new List <string>();
                    for (int i = 0; i < myReader.FieldCount; i++)
                    {
                        monsterAttList.Add(myReader.GetValue(i).ToString());
                    }

                    MonsterAttributes monAtt = new MonsterAttributes();
                    AssignAttributes(monAtt, monsterAttList);
                    string completeMon = JsonConvert.SerializeObject(monAtt);
                    File.WriteAllText(@Application.UserAppDataPath + "/Monster_Lists/monsterList" + listView1.Items.Count + ".json", completeMon);

                    string[] monsterRow = new string[] { monAtt.id.ToString(), myReader.GetString(1),
                                                         myReader.GetString(2), myReader.GetString(3) };

                    ListViewItem newItem = new ListViewItem(monsterRow);
                    listView1.Items.Add(newItem);
                }

                textBox10.Text = totalXP.ToString();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #6
0
        private void TransferAllMonsters()
        {
            // transfers all monsters from listview1 to listview2 and rolls initiative and hp
            if (listView1.Items.Count > 0)
            {
                ClearEncounterListView();
                string        filePath = @Application.UserAppDataPath + "/Monster_Lists";
                DirectoryInfo d        = new DirectoryInfo(filePath);

                foreach (var file in d.GetFiles("*.json"))
                {
                    MonsterAttributes monAtts = JsonConvert.DeserializeObject <MonsterAttributes>(File.ReadAllText(file.DirectoryName + "/" + file));
                    string            health  = monAtts.hp.ToString();

                    ListViewItem newItem = new ListViewItem(new string[] { monAtts.name, monAtts.initiative.ToString(), health, monAtts.id.ToString() });
                    monsterNames.Add(newItem);
                    listView2.Items.Add(newItem);
                }
                ReAddPlayerNames();
            }
        }
Beispiel #7
0
        private void PopulateViewList(int chl)
        {
            string conString = "datasource=localhost;port=3306;username=root;password=SuperAdmin1!;";
            string query     = "SELECT * FROM monster_database.monster_list WHERE Challenge='" + chl + "' ORDER BY RAND() LIMIT 1;";

            MySqlConnection conDatabase = new MySqlConnection(conString);
            MySqlCommand    cmdDatabase = new MySqlCommand(query, conDatabase);
            MySqlDataReader myReader;

            try {
                int totalXP = int.Parse(textBox10.Text);
                conDatabase.Open();
                myReader = cmdDatabase.ExecuteReader();
                while (myReader.Read())
                {
                    //totalXP += myReader.GetInt32("XP");
                    // add to json file
                    List <string> monsterAttList = new List <string>();
                    for (int i = 0; i < myReader.FieldCount; i++)
                    {
                        monsterAttList.Add(myReader.GetValue(i).ToString());
                    }
                    MonsterAttributes monAtt = new MonsterAttributes();
                    AssignAttributes(monAtt, monsterAttList);
                    string completeMon = JsonConvert.SerializeObject(monAtt);
                    File.WriteAllText(@Application.UserAppDataPath + "/Monster_Lists/monsterList" + listView1.Items.Count + ".json", completeMon);


                    string[] monsterRow = new string[] { myReader.GetString("Name"), myReader.GetString("Size"),
                                                         myReader.GetString("Type"), myReader.GetInt32("Challenge").ToString() };

                    ListViewItem newItem = new ListViewItem(monsterRow);
                    listView1.Items.Add(newItem);
                }

                textBox10.Text = totalXP.ToString();
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }