// Function from file: random_books.dm public override void initialize( ) { Obj_Item_Weapon_Paper P = null; string c = null; DBQuery query = null; Obj_Item_Weapon_Book B = null; if (!(this.book_count != 0) || !Lang13.Bool(Lang13.IsNumber(this.book_count))) { this.update_icon(); return; } if (!GlobalFuncs.establish_db_connection()) { if (Rand13.PercentChance(5)) { P = new Obj_Item_Weapon_Paper(GlobalFuncs.get_turf(this.loc)); P.info = "There once was a book from Nantucket<br>But the database failed us, so f*$! it.<br>I tried to be good to you<br>Now this is an I.O.U<br>If you're feeling entitled, well, stuff it!<br><br><font color='gray'>~</font>"; } this.update_icon(); return; } if (Lang13.Bool(this.category) && Rand13.PercentChance(25)) { this.category = null; } this.book_count += Convert.ToDouble(Rand13.Pick(new object [] { -1, -1, 0, 1, 1 })); if (this.book_count <= 0) { this.update_icon(); return; } c = (Lang13.Bool(this.category) ? " AND category='" + GlobalFuncs.sanitizeSQL(this.category) + "'" : ""); query = GlobalVars.dbcon.NewQuery("SELECT * FROM " + GlobalFuncs.format_table_name("library") + " WHERE isnull(deleted)" + c + " GROUP BY title ORDER BY rand() LIMIT " + this.book_count + ";"); if (query.Execute()) { while (query.NextRow()) { B = new Obj_Item_Weapon_Book(this); B.author = query.item[2]; B.title = query.item[3]; B.dat = query.item[4]; B.name = "Book: " + B.title; B.icon_state = "book" + Rand13.Int(1, 8); } } else { GlobalFuncs.log_game("SQL ERROR populating library bookshelf. Category: [" + this.category + "], Count: " + this.book_count + ", Error: [" + query.ErrorMsg() + "]\n"); } this.update_icon(); return; }
// Function from file: lib_machines.dm public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null) { Obj_Item_Weapon_Book B = null; Obj_Item_Weapon_Book B2 = null; if (Lang13.Bool(base.Topic(href, href_list, (object)(hsrc)))) { Interface13.Browse(Task13.User, null, "window=scanner"); GlobalFuncs.onclose(Task13.User, "scanner"); return(null); } if (Lang13.Bool(href_list["scan"])) { foreach (dynamic _a in Lang13.Enumerate(this.contents, typeof(Obj_Item_Weapon_Book))) { B = _a; this.cache = B; break; } } if (Lang13.Bool(href_list["clear"])) { this.cache = null; } if (Lang13.Bool(href_list["eject"])) { foreach (dynamic _b in Lang13.Enumerate(this.contents, typeof(Obj_Item_Weapon_Book))) { B2 = _b; B2.loc = this.loc; } } this.add_fingerprint(Task13.User); this.updateUsrDialog(); return(null); }
// Function from file: lib_items.dm public override bool ex_act(double?severity = null, dynamic target = null) { Obj_Item_Weapon_Book b = null; base.ex_act(severity, (object)(target)); if (!Lang13.Bool(this.gc_destroyed)) { foreach (dynamic _a in Lang13.Enumerate(this.contents, typeof(Obj_Item_Weapon_Book))) { b = _a; b.loc = GlobalFuncs.get_turf(this); } if (Rand13.PercentChance(50)) { GlobalFuncs.qdel(this); } } return(false); }
// Function from file: lib_machines.dm public override dynamic attackby(dynamic A = null, dynamic user = null, string _params = null, bool?silent = null, bool?replace_spent = null) { Obj_Item_Weapon_Book b = null; if (A is Obj_Item_Weapon_Paper) { if (this.busy) { user.WriteMsg("<span class='warning'>The book binder is busy. Please wait for completion of previous operation.</span>"); return(null); } if (!Lang13.Bool(user.drop_item())) { return(null); } A.loc = this; ((Ent_Static)user).visible_message("" + user + " loads some paper into " + this + ".", "You load some paper into " + this + "."); this.visible_message("" + this + " begins to hum as it warms up its printing drums."); this.busy = true; Task13.Sleep(Rand13.Int(200, 400)); this.busy = false; this.visible_message("" + this + " whirs as it prints and binds a new book."); b = new Obj_Item_Weapon_Book(this.loc); b.dat = A.info; b.name = "Print Job #" + ("" + Rand13.Int(100, 999)); b.icon_state = "book" + Rand13.Int(1, 7); GlobalFuncs.qdel(A); } else { base.attackby((object)(A), (object)(user), _params, silent, replace_spent); } return(null); }
// Function from file: lib_machines.dm public override dynamic Topic(string href = null, ByTable href_list = null, dynamic hsrc = null) { Obj_Item_Weapon_Storage_Book_Bible B = null; Borrowbook b = null; dynamic b2 = null; dynamic b3 = null; string newauthor = null; dynamic newcategory = null; dynamic choice = null; string sqltitle = null; string sqlauthor = null; string sqlcontent = null; string sqlcategory = null; DBQuery query = null; dynamic orderid = null; string sqlid = null; DBQuery query2 = null; dynamic author = null; dynamic title = null; dynamic content = null; Obj_Item_Weapon_Book B2 = null; if (Lang13.Bool(base.Topic(href, href_list, (object)(hsrc)))) { Interface13.Browse(Task13.User, null, "window=library"); GlobalFuncs.onclose(Task13.User, "library"); return(null); } if (Lang13.Bool(href_list["page"]) && this.screenstate == 4) { this.page = String13.ParseNumber(href_list["page"]); } if (Lang13.Bool(href_list["switchscreen"])) { dynamic _a = href_list["switchscreen"]; // Was a switch-case, sorry for the mess. if (_a == "0") { this.screenstate = 0; } else if (_a == "1") { this.screenstate = 1; } else if (_a == "2") { this.screenstate = 2; } else if (_a == "3") { this.screenstate = 3; } else if (_a == "4") { this.screenstate = 4; } else if (_a == "5") { this.screenstate = 5; } else if (_a == "6") { if (!this.bibledelay) { B = new Obj_Item_Weapon_Storage_Book_Bible(this.loc); if (GlobalVars.ticker != null && Lang13.Bool(GlobalVars.ticker.Bible_icon_state) && Lang13.Bool(GlobalVars.ticker.Bible_item_state)) { B.icon_state = GlobalVars.ticker.Bible_icon_state; B.item_state = GlobalVars.ticker.Bible_item_state; B.name = GlobalVars.ticker.Bible_name; B.deity_name = GlobalVars.ticker.Bible_deity_name; } this.bibledelay = true; Task13.Schedule(60, (Task13.Closure)(() => { this.bibledelay = false; return; })); } else { this.say("Bible printer currently unavailable, please wait a moment."); } } else if (_a == "7") { this.screenstate = 7; } } if (Lang13.Bool(href_list["arccheckout"])) { if (Lang13.Bool(this.emagged)) { this.arcanecheckout = true; } this.screenstate = 0; } if (Lang13.Bool(href_list["increasetime"])) { this.checkoutperiod += 1; } if (Lang13.Bool(href_list["decreasetime"])) { this.checkoutperiod -= 1; if (this.checkoutperiod < 1) { this.checkoutperiod = 1; } } if (Lang13.Bool(href_list["editbook"])) { this.buffer_book = String13.SubStr(GlobalFuncs.sanitize(Interface13.Input("Enter the book's title:", null, null, null, null, InputType.Str | InputType.Null)), 1, 1024); } if (Lang13.Bool(href_list["editmob"])) { this.buffer_mob = String13.SubStr(GlobalFuncs.sanitize(Interface13.Input("Enter the recipient's name:", null, null, null, null, InputType.Str | InputType.Null)), 1, 26); } if (Lang13.Bool(href_list["checkout"])) { b = new Borrowbook(); b.bookname = GlobalFuncs.sanitize(this.buffer_book); b.mobname = GlobalFuncs.sanitize(this.buffer_mob); b.getdate = Game13.time; b.duedate = Game13.time + this.checkoutperiod * 600; this.checkouts.Add(b); } if (Lang13.Bool(href_list["checkin"])) { b2 = Lang13.FindObj(href_list["checkin"]); this.checkouts.Remove(b2); } if (Lang13.Bool(href_list["delbook"])) { b3 = Lang13.FindObj(href_list["delbook"]); this.inventory.Remove(b3); } if (Lang13.Bool(href_list["setauthor"])) { newauthor = String13.SubStr(GlobalFuncs.sanitize(Interface13.Input("Enter the author's name: ", null, null, null, null, InputType.Str | InputType.Null)), 1, 1024); if (Lang13.Bool(newauthor)) { this.scanner.cache.author = newauthor; } } if (Lang13.Bool(href_list["setcategory"])) { newcategory = Interface13.Input("Choose a category: ", null, null, null, new ByTable(new object [] { "Fiction", "Non-Fiction", "Adult", "Reference", "Religion" }), InputType.Any); if (Lang13.Bool(newcategory)) { this.upload_category = newcategory; } } if (Lang13.Bool(href_list["upload"])) { if (this.scanner != null) { if (this.scanner.cache != null) { choice = Interface13.Input("Are you certain you wish to upload this title to the Archive?", null, null, null, new ByTable(new object [] { "Confirm", "Abort" }), InputType.Any); if (choice == "Confirm") { GlobalFuncs.establish_db_connection(); if (!GlobalVars.dbcon.IsConnected()) { Interface13.Alert("Connection to Archive has been severed. Aborting."); } else { sqltitle = GlobalFuncs.sanitizeSQL(this.scanner.cache.name); sqlauthor = GlobalFuncs.sanitizeSQL(this.scanner.cache.author); sqlcontent = GlobalFuncs.sanitizeSQL(this.scanner.cache.dat); sqlcategory = GlobalFuncs.sanitizeSQL(this.upload_category); query = GlobalVars.dbcon.NewQuery("INSERT INTO " + GlobalFuncs.format_table_name("library") + " (author, title, content, category, ckey, datetime) VALUES ('" + sqlauthor + "', '" + sqltitle + "', '" + sqlcontent + "', '" + sqlcategory + "', '" + Task13.User.ckey + "', Now())"); if (!query.Execute()) { Task13.User.WriteMsg(query.ErrorMsg()); } else { GlobalFuncs.log_game("" + Task13.User.name + "/" + Task13.User.key + " has uploaded the book titled " + this.scanner.cache.name + ", " + Lang13.Length(this.scanner.cache.dat) + " signs"); Interface13.Alert("Upload Complete. Uploaded title will be unavailable for printing for a short period"); } } } } } } if (Lang13.Bool(href_list["orderbyid"])) { orderid = Interface13.Input("Enter your order:", null, null, null, null, InputType.Num | InputType.Null); if (Lang13.Bool(orderid)) { if (Lang13.Bool(Lang13.IsNumber(orderid))) { href_list["targetid"] = orderid; } } } if (Lang13.Bool(href_list["targetid"])) { sqlid = GlobalFuncs.sanitizeSQL(href_list["targetid"]); GlobalFuncs.establish_db_connection(); if (!GlobalVars.dbcon.IsConnected()) { Interface13.Alert("Connection to Archive has been severed. Aborting."); } if (this.bibledelay) { this.say("Printer unavailable. Please allow a short time before attempting to print."); } else { this.bibledelay = true; Task13.Schedule(60, (Task13.Closure)(() => { this.bibledelay = false; return; })); query2 = GlobalVars.dbcon.NewQuery("SELECT * FROM " + GlobalFuncs.format_table_name("library") + " WHERE id=" + sqlid + " AND isnull(deleted)"); query2.Execute(); while (query2.NextRow()) { author = query2.item[2]; title = query2.item[3]; content = query2.item[4]; B2 = new Obj_Item_Weapon_Book(this.loc); B2.name = "Book: " + title; B2.title = title; B2.author = author; B2.dat = content; B2.icon_state = "book" + Rand13.Int(1, 8); this.visible_message("" + this + "'s printer hums as it produces a completely bound book. How did it do that?"); break; } } } this.add_fingerprint(Task13.User); this.updateUsrDialog(); return(null); }
// Function from file: lib_machines.dm public override dynamic interact(dynamic user = null, bool?flag1 = null) { string dat = null; Obj_Item_Weapon_Book b = null; Borrowbook b2 = null; double timetaken = 0; dynamic timedue = null; Obj_Machinery_Libraryscanner S = null; Browser popup = null; ((Mob)user).set_machine(this); dat = ""; switch ((int)(this.screenstate)) { case 0: dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=1'>1. View General Inventory</A><BR>").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=2'>2. View Checked Out Inventory</A><BR>").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=3'>3. Check out a Book</A><BR>").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=4'>4. Connect to External Archive</A><BR>").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=5'>5. Upload New Title to Archive</A><BR>").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=6'>6. Print a Bible</A><BR>").ToString(); if (Lang13.Bool(this.emagged)) { dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=7'>7. Access the Forbidden Lore Vault</A><BR>").ToString(); } if (this.arcanecheckout) { new Obj_Item_Weapon_Tome(this.loc); user.WriteMsg("<span class='warning'>Your sanity barely endures the seconds spent in the vault's browsing window. The only thing to remind you of this when you stop browsing is a dusty old tome sitting on the desk. You don't really remember printing it.</span>"); ((Ent_Static)user).visible_message("" + user + " stares at the blank screen for a few moments, his expression frozen in fear. When he finally awakens from it, he looks a lot older.", 2); this.arcanecheckout = false; } break; case 1: dat += "<H3>Inventory</H3><BR>"; foreach (dynamic _a in Lang13.Enumerate(this.inventory, typeof(Obj_Item_Weapon_Book))) { b = _a; dat += new Txt().item(b.name).str(" <A href='?src=").Ref(this).str(";delbook=").Ref(b).str("'>(Delete)</A><BR>").ToString(); } dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=0'>(Return to main menu)</A><BR>").ToString(); break; case 2: dat += "<h3>Checked Out Books</h3><BR>"; foreach (dynamic _b in Lang13.Enumerate(this.checkouts, typeof(Borrowbook))) { b2 = _b; timetaken = Game13.time - b2.getdate; timetaken /= 600; timetaken = Num13.Floor(timetaken); timedue = b2.duedate - Game13.time; timedue /= 600; if (Convert.ToDouble(timedue) <= 0) { timedue = "<font color=red><b>(OVERDUE)</b> " + timedue + "</font>"; } else { timedue = Num13.Floor(Convert.ToDouble(timedue)); } dat += "\"" + b2.bookname + "\", Checked out to: " + b2.mobname + "<BR>--- Taken: " + timetaken + " minutes ago, Due: in " + timedue + " minutes<BR>"; dat += new Txt("<A href='?src=").Ref(this).str(";checkin=").Ref(b2).str("'>(Check In)</A><BR><BR>").ToString(); } dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=0'>(Return to main menu)</A><BR>").ToString(); break; case 3: dat += "<h3>Check Out a Book</h3><BR>"; dat += "Book: " + this.buffer_book + " "; dat += new Txt("<A href='?src=").Ref(this).str(";editbook=1'>[Edit]</A><BR>").ToString(); dat += "Recipient: " + this.buffer_mob + " "; dat += new Txt("<A href='?src=").Ref(this).str(";editmob=1'>[Edit]</A><BR>").ToString(); dat += "Checkout Date : " + Game13.time / 600 + "<BR>"; dat += "Due Date: " + (Game13.time + this.checkoutperiod) / 600 + "<BR>"; dat += new Txt("(Checkout Period: ").item(this.checkoutperiod).str(" minutes) (<A href='?src=").Ref(this).str(";increasetime=1'>+</A>/<A href='?src=").Ref(this).str(";decreasetime=1'>-</A>)").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";checkout=1'>(Commit Entry)</A><BR>").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=0'>(Return to main menu)</A><BR>").ToString(); break; case 4: dat += "<h3>External Archive</h3>"; this.build_library_menu(); if (!(GlobalVars.cachedbooks != null)) { dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font>"; } else { dat += new Txt("<A href='?src=").Ref(this).str(";orderbyid=1'>(Order book by SS<sup>13</sup>BN)</A><BR><BR>").ToString(); dat += "<table>"; dat += "<tr><td>AUTHOR</td><td>TITLE</td><td>CATEGORY</td><td></td></tr>"; dat += this.libcomp_menu[Num13.MaxInt(1, Num13.MinInt(((int)(this.page ?? 0)), this.libcomp_menu.len))]; dat += new Txt("<tr><td><A href='?src=").Ref(this).str(";page=").item(Num13.MaxInt(1, ((int)((this.page ?? 0) - 1)))).str("'><<<<</A></td> <td></td> <td></td> <td><span style='text-align:right'><A href='?src=").Ref(this).str(";page=").item(Num13.MinInt(this.libcomp_menu.len, ((int)((this.page ?? 0) + 1)))).str("'>>>>></A></span></td></tr>").ToString(); dat += "</table>"; } dat += new Txt("<BR><A href='?src=").Ref(this).str(";switchscreen=0'>(Return to main menu)</A><BR>").ToString(); break; case 5: dat += "<H3>Upload a New Title</H3>"; if (!(this.scanner != null)) { foreach (dynamic _c in Lang13.Enumerate(Map13.FetchInRange(null, 9), typeof(Obj_Machinery_Libraryscanner))) { S = _c; this.scanner = S; break; } } if (!(this.scanner != null)) { dat += "<FONT color=red>No scanner found within wireless network range.</FONT><BR>"; } else if (!(this.scanner.cache != null)) { dat += "<FONT color=red>No data found in scanner memory.</FONT><BR>"; } else { dat += "<TT>Data marked for upload...</TT><BR>"; dat += "<TT>Title: </TT>" + this.scanner.cache.name + "<BR>"; if (!Lang13.Bool(this.scanner.cache.author)) { this.scanner.cache.author = "Anonymous"; } dat += new Txt("<TT>Author: </TT><A href='?src=").Ref(this).str(";setauthor=1'>").item(this.scanner.cache.author).str("</A><BR>").ToString(); dat += new Txt("<TT>Category: </TT><A href='?src=").Ref(this).str(";setcategory=1'>").item(this.upload_category).str("</A><BR>").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";upload=1'>[Upload]</A><BR>").ToString(); } dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=0'>(Return to main menu)</A><BR>").ToString(); break; case 7: dat += "<h3>Accessing Forbidden Lore Vault v 1.3</h3>"; dat += "Are you absolutely sure you want to proceed? EldritchTomes Inc. takes no responsibilities for loss of sanity resulting from this action.<p>"; dat += new Txt("<A href='?src=").Ref(this).str(";arccheckout=1'>Yes.</A><BR>").ToString(); dat += new Txt("<A href='?src=").Ref(this).str(";switchscreen=0'>No.</A><BR>").ToString(); break; } popup = new Browser(user, "library", this.name, 600, 400); popup.set_content(dat); popup.set_title_image(((Mob)user).browse_rsc_icon(this.icon, this.icon_state)); popup.open(); return(null); }