private void SuggestItem(n8 gclass11, ig gclass10) { if (gclass11.bt() == f2.InteractionType.Initialize) { foreach (Item item in Game.User.zr.Values) { if (gclass10.agm.ajb().ep(item.Data.Type)) { Game.SimManager.SendUserAction("VisitorInteract", new Dictionary <string, object> { { "id", gclass10.cw() }, { "type", 8 }, { "itemId", item.m8 } }); } } } }
public static void Sort() { for (int i = 0; i < cont - 1; i++) { for (int j = i + 1; j < cont; j++) { if (movements[i].date.CompareTo(movements[j].date) > 0) { ig aux = movements[j]; movements[j] = movements[i]; movements[i] = aux; } else if (movements[i].date == movements[j].date && String.Compare(movements[i].description, movements[j].description, true) > 0) { ig aux = movements[j]; movements[j] = movements[i]; movements[i] = aux; } } } Console.WriteLine("Data stored!"); }
private void StartConversationWithNpc(ig gclass10) { Game.SimManager.SendUserAction("VisitorInteract", new Dictionary <string, object> { { "id", gclass10.cw() }, { "type", 1 } }); }
private void RefuseItem(n8 gclass11, ig gclass10) { if (gclass11.bt() == f2.InteractionType.Initialize) { Game.SimManager.SendUserAction("VisitorInteract", new Dictionary <string, object> { { "id", gclass10.cw() }, { "type", 2 } }); } }
private void SurchargeOrDiscount(ig gclass10) { if (Game.User.ajn() < Game.User.ajo() / 2) { Game.SimManager.SendUserAction("VisitorInteract", new Dictionary <string, object> { { "id", gclass10.cw() }, { "type", 7 } }); } else if (Game.User.ajn() == Game.User.ajo()) { Game.SimManager.SendUserAction("VisitorInteract", new Dictionary <string, object> { { "id", gclass10.cw() }, { "type", 6 } }); } Game.SimManager.SendUserAction("VisitorInteract", new Dictionary <string, object> { { "id", gclass10.cw() }, { "type", 9 } }); }
public static void Main() { const ushort SIZE = 10000; ig[] movements = new ig[SIZE]; string option; int cont = 0; int numMove; do { Console.WriteLine("1. Add expense"); Console.WriteLine("2. Show expense"); Console.WriteLine("3. Search"); Console.WriteLine("4. Modify movement data"); Console.WriteLine("5. Delete movement"); Console.WriteLine("6. Sort alphabetically"); Console.WriteLine("7. Normalize descriptions"); Console.WriteLine("t. Exit"); Console.Write("Option: "); option = Console.ReadLine().ToLower(); Console.Clear(); bool found = false; switch (option) { case "1": // Add string year, month, day; if (cont < SIZE) { do { Console.Write("Enter year: "); year = Console.ReadLine(); }while ((Convert.ToInt32(year) < 1000) || (Convert.ToInt32(year) > 3000)); do { Console.Write("Enter month: "); month = Console.ReadLine(); }while ((Convert.ToInt32(month) < 1) || (Convert.ToInt32(month) > 12)); if (month.Length == 1) { month = "0" + month; } do { Console.Write("Enter day: "); day = Console.ReadLine(); }while ((Convert.ToInt32(day) < 1) || (Convert.ToInt32(day) > 31)); if (day.Length == 1) { day = "0" + day; } movements[cont].date = year + month + day; do { Console.Write("Description: "); movements[cont].description = Console.ReadLine(); if (movements[cont].description == "") { Console.WriteLine("Description cannot be empty"); } } while (movements[cont].description == ""); Console.Write("Category: "); movements[cont].category = Console.ReadLine(); Console.Write("Amount: "); movements[cont].amount = Convert.ToDouble(Console.ReadLine()); cont++; } else { Console.WriteLine("No room"); } break; case "2": // Show double sumTotal = 0; if (cont > 0) { Console.Write("Category: "); string auxCategory = Console.ReadLine(); Console.Write("From: "); int fromDate = Convert.ToInt32(Console.ReadLine()); Console.Write("To: "); int toDate = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < cont; i++) { if (movements[i].category.Contains(auxCategory) && (Convert.ToInt32(movements[i].date) >= fromDate && Convert.ToInt32(movements[i].date) <= toDate)) { Console.WriteLine((i + 1) + " - " + movements[i].date.Substring(6, 2) + "/" + movements[i].date.Substring(4, 2) + "/" + movements[i].date.Substring(0, 4) + " - " + movements[i].description + " - (" + movements[i].category + ") - " + movements[i].amount.ToString("0.00")); sumTotal += movements[i].amount; } } Console.WriteLine("Total amount: " + sumTotal.ToString("0.00")); } else { Console.WriteLine("There are no expenses"); } break; case "3": // Search Console.Write("Search: "); string search = Console.ReadLine().ToUpper(); if (cont > 0) { for (int i = 0; i < cont; i++) { int contSpaces = 0; int numList = i + 1; if (movements[i].description.ToUpper().Contains(search) || movements[i].category.ToUpper().Contains(search)) { Console.Write((numList) + " - " + movements[i].date.Substring(6, 2) + "/" + movements[i].date.Substring(4, 2) + "/" + movements[i].date.Substring(0, 4) + " - "); foreach (char c in movements[i].description) { if (c == ' ') { contSpaces++; } if (contSpaces <= 6) { Console.Write(c); } } Console.WriteLine(); found = true; } } if (found == false) { Console.WriteLine("Not found"); } } else { Console.WriteLine("There are no expenses"); } break; case "4": // Edit Console.Write("Number of movement: "); numMove = Convert.ToUInt16(Console.ReadLine()) - 1; if (numMove >= 0 && numMove < cont) { Console.WriteLine("Date (" + movements[numMove].date + "): "); string answer = Console.ReadLine(); if (answer != "") { movements[numMove].date = answer; } Console.WriteLine("Category (" + movements[numMove].category + "): "); answer = Console.ReadLine(); if (answer != "") { movements[numMove].category = answer; } Console.WriteLine("Description (" + movements[numMove].description + "): "); answer = Console.ReadLine(); if (answer != "") { movements[numMove].description = answer; } Console.WriteLine("Amount (" + movements[numMove].amount + "): "); answer = Console.ReadLine(); if (answer != "") { movements[numMove].amount = Convert.ToDouble(answer); } } else { Console.WriteLine("Wrong number"); } break; case "5": // Delete Console.Write("Number of movement: "); numMove = Convert.ToUInt16(Console.ReadLine()) - 1; string confirm = ""; if (numMove >= 0 && numMove < cont) { Console.WriteLine("Are you sure? S/N"); confirm = Console.ReadLine(); if (confirm == "S" || confirm == "s") { for (int i = numMove; i < cont - 1; i++) { movements[i] = movements[i + 1]; } cont--; Console.WriteLine("Delete successful"); } else { Console.WriteLine("Delete not processed"); } } else { Console.WriteLine("Wrong number"); } break; case "6": // Sort for (int i = 0; i < cont - 1; i++) { for (int j = i + 1; j < cont; j++) { if (movements[i].date.CompareTo(movements[j].date) > 0) { ig aux = movements[j]; movements[j] = movements[i]; movements[i] = aux; } else if (movements[i].date == movements[j].date && String.Compare(movements[i].description, movements[j].description, true) > 0) { ig aux = movements[j]; movements[j] = movements[i]; movements[i] = aux; } } } Console.WriteLine("Data stored!"); break; case "7": // Normalize for (int i = 0; i < cont; i++) { // Leading and trailing spaces movements[i].description = movements[i].description.Trim(); // Duplicated spaces while (movements[i].description.Contains(" ")) { movements[i].description = movements[i].description. Replace(" ", " "); } // Correct case if (movements[i].description == movements[i].description.ToUpper()) { movements[i].description = movements[i].description.Substring(0, 1).ToUpper() + movements[i].description.Substring(1).ToLower(); } } break; case "t": Console.WriteLine("Bye!"); break; default: Console.WriteLine("Wrong option!"); break; } if (option != "t") { Console.WriteLine("Press Enter to continue"); Console.ReadLine(); Console.Clear(); } } while (option != "t"); }