diff --git a/Cargo.lock b/Cargo.lock index 62429a39..55f3ae79 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,237 +1,237 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "bitflags" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" [[package]] name = "cc" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c37f0efaa4b9b001fa6f02d4b644dee4af97d3414df07c51e3e4f015f3a3e131" [[package]] name = "cfg-if" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" [[package]] name = "dtoa" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" [[package]] name = "fuchsia-zircon" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "fuchsia-zircon-sys", ] [[package]] name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "itoa" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" [[package]] name = "lazy_static" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" dependencies = [ - "version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "version_check", ] [[package]] name = "libc" version = "0.2.42" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" [[package]] name = "log" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "ncurses" version = "5.94.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a02f0da600c09fa2e5fd6479093ba8a4b21f4ed5bed3b6ddc26583b50d31319" dependencies = [ - "cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "pkg-config", ] [[package]] name = "omoria" version = "0.1.0" dependencies = [ - "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "pancurses 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", + "libc", + "pancurses", + "rand", + "serde", + "serde_derive", + "serde_json", ] [[package]] name = "pancurses" version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cedc1409ecbb0a789f39e2a90ae052df6670c1e1c17724587e1872e6ec270e56" dependencies = [ - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "ncurses 5.94.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pdcurses-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "log", + "ncurses", + "pdcurses-sys", + "winreg", ] [[package]] name = "pdcurses-sys" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e12bfe55b7080fdfa0742f7a22ce7d5d1da250ca064ae6b81c843a2084fa2a" dependencies = [ - "cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", ] [[package]] name = "pkg-config" version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" [[package]] name = "proc-macro2" version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "762eea716b821300a86da08870a64b597304866ceb9f54a11d67b4cf56459c6a" dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", ] [[package]] name = "quote" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3372dc35766b36a99ce2352bd1b6ea0137c38d215cc0c8780bf6de6df7842ba9" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "rand" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon", + "libc", + "winapi", ] [[package]] name = "serde" version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dfad05c8854584e5f72fb859385ecdfa03af69c3fd0572f0da2d4c95f060bdb" [[package]] name = "serde_derive" version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b719c6d5e9f73fbc37892246d5852333f040caa617b8873c6aced84bcb28e7bb" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "serde_json" version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c6908c7b925cd6c590358a4034de93dbddb20c45e1d021931459fd419bf0e2" dependencies = [ - "dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)", + "dtoa", + "itoa", + "serde", ] [[package]] name = "syn" version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e13df71f29f9440b50261a5882c86eac334f1badb3134ec26f0de2f1418e44" dependencies = [ - "proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" [[package]] name = "version_check" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" [[package]] name = "winapi" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winreg" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] - -[metadata] -"checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" -"checksum cc 1.0.23 (registry+https://github.com/rust-lang/crates.io-index)" = "c37f0efaa4b9b001fa6f02d4b644dee4af97d3414df07c51e3e4f015f3a3e131" -"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" -"checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum itoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5adb58558dcd1d786b5f0bd15f3226ee23486e24b7b58304b60f64dc68e62606" -"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7" -"checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" -"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" -"checksum ncurses 5.94.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4a02f0da600c09fa2e5fd6479093ba8a4b21f4ed5bed3b6ddc26583b50d31319" -"checksum pancurses 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cedc1409ecbb0a789f39e2a90ae052df6670c1e1c17724587e1872e6ec270e56" -"checksum pdcurses-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "90e12bfe55b7080fdfa0742f7a22ce7d5d1da250ca064ae6b81c843a2084fa2a" -"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum proc-macro2 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "762eea716b821300a86da08870a64b597304866ceb9f54a11d67b4cf56459c6a" -"checksum quote 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3372dc35766b36a99ce2352bd1b6ea0137c38d215cc0c8780bf6de6df7842ba9" -"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" -"checksum serde 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)" = "6dfad05c8854584e5f72fb859385ecdfa03af69c3fd0572f0da2d4c95f060bdb" -"checksum serde_derive 1.0.71 (registry+https://github.com/rust-lang/crates.io-index)" = "b719c6d5e9f73fbc37892246d5852333f040caa617b8873c6aced84bcb28e7bb" -"checksum serde_json 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c3c6908c7b925cd6c590358a4034de93dbddb20c45e1d021931459fd419bf0e2" -"checksum syn 0.14.7 (registry+https://github.com/rust-lang/crates.io-index)" = "e2e13df71f29f9440b50261a5882c86eac334f1badb3134ec26f0de2f1418e44" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051" -"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum winreg 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" diff --git a/README.md b/README.md index a3a31bf1..5b240fae 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ bugs you would like. ## Requirements * Modern GCC (Game won't run with other compilers) -* Rustc +* Rustc (v1.61) * Curses * Termcap * Pthreads diff --git a/STRUCTURE.md b/STRUCTURE.md index ca3a0bc4..cfbf763b 100644 --- a/STRUCTURE.md +++ b/STRUCTURE.md @@ -38,8 +38,6 @@ Modules; - The public pregame function can only be called from pregame/main.c - pregame/main.h can only be called from the main()-function - pregame/*.c can use any file in /src/logic or /src/model - -/src/template - Templates of models ``` ## Namespaces diff --git a/src/blackmarket.c b/src/blackmarket.c deleted file mode 100644 index 2b24c03f..00000000 --- a/src/blackmarket.c +++ /dev/null @@ -1,825 +0,0 @@ -/* blackmarket.c */ -/**/ - -#include -#include -#include -#include -#include -#include -#include /* for ftruncate, usleep */ - -#include "configure.h" -#include "constants.h" -#include "debug.h" -#include "dungeon.h" -#include "magic.h" -#include "pascal.h" -#include "routines.h" -#include "term.h" -#include "types.h" -#include "variables.h" - -static void bm__add_tohit(long a, long b, long c, long i, long *r) { - *r = randint(a) + randint(b) + randint(c); - t_list[i].tohit = *r; -} - -static void bm__add_todam(long a, long b, long c, long i, long *r) { - *r = randint(a) + randint(b) + randint(c); - t_list[i].todam = *r; -} - -static void bm__add_ac(long a, long b, long c, long i, long *r) { - *r = randint(a) + randint(b) + randint(c); - t_list[i].ac = *r; -} - -static void bm__add_toac(long a, long b, long c, long i, long *r) { - *r = randint(a) + randint(b) + randint(c); - t_list[i].toac = *r; -} - -static void bm__add_p1(long a, long b, long c, long i, long *r) { - *r = a + randint(b) + randint(c); - t_list[i].p1 = *r; -} - -static void bm__add_p1_rods(long a, long b, long c, long i, long *r) { - *r = a + randint(b) + c; - t_list[i].p1 = *r; -} - -void soup_up_black_market(long indx) { - /*{ Soup-up the Black Market inventory - mwk}*/ - - long r1, r2, r3, r4, r5; - - /* with t_list[indx]. do; */ - switch (t_list[indx].tval) { - - case sling_ammo: - case arrow: - case bolt: - switch (randint(10)) { - case 1: - case 2: - case 3: - strcat(t_list[indx].name, " of Slaying"); - bm__add_tohit(5, 5, 1, indx, &r1); - bm__add_todam(5, 5, 1, indx, &r2); - t_list[indx].cost += 1250 * r1 + 1250 * r2; - break; - - case 4: - case 5: - t_list[indx].flags |= 0x00040000; - strcat(t_list[indx].name, " of Fire"); - bm__add_tohit(4, 4, 1, indx, &r1); - bm__add_todam(4, 4, 1, indx, &r2); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - break; - - case 6: - case 7: - t_list[indx].flags |= 0x00008000; - strcat(t_list[indx].name, " of Slay Evil"); - bm__add_tohit(4, 4, 1, indx, &r1); - bm__add_todam(4, 4, 1, indx, &r2); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - break; - - case 8: - case 9: - t_list[indx].flags |= 0x00004000; - strcat(t_list[indx].name, " of Slay Monster"); - bm__add_tohit(3, 2, 1, indx, &r1); - bm__add_todam(3, 2, 1, indx, &r2); - t_list[indx].cost += 900 * r1 + 900 * r1; - break; - - case 10: - t_list[indx].flags |= 0x00002000; - strcat(t_list[indx].name, " of Dragon Slaying"); - bm__add_tohit(8, 8, 1, indx, &r1); - bm__add_todam(8, 8, 1, indx, &r2); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - break; - - default: - break; - }; - - t_list[indx].number = 0; - for (r1 = 1; r1 <= 7; r1++) { - t_list[indx].number += randint(12); - } - missle_ctr++; - if (missle_ctr > 65534) { - missle_ctr = 1; - } - t_list[indx].subval = missle_ctr + 512; - break; - - case bow_crossbow_or_sling: - bm__add_tohit(5, 5, 1, indx, &r1); - t_list[indx].cost += 1000 * r1 + 10000; - break; - - case hafted_weapon: - case pole_arm: - case dagger: - case sword: - switch (randint(16)) { - case 1: - case 9: - t_list[indx].flags |= 0x01418001; - strcat(t_list[indx].name, " (HA)"); - bm__add_tohit(6, 6, 1, indx, &r1); - bm__add_todam(6, 6, 1, indx, &r2); - bm__add_toac(5, 1, 1, indx, &r4); - bm__add_p1(1, 4, 1, indx, &r5); /*{for sustain stat}*/ - t_list[indx].cost += 1000 * r1 + 1000 * r2; - t_list[indx].cost += 2000 * r4; - t_list[indx].cost += 20000; - break; - - case 2: - case 10: - t_list[indx].flags |= 0x07B80900; - strcat(t_list[indx].name, " [%P4] (DF)"); - bm__add_tohit(6, 6, 1, indx, &r1); - bm__add_todam(6, 6, 1, indx, &r2); - bm__add_toac(5, 5, 8, indx, &r4); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - t_list[indx].cost += 2000 * r4; - t_list[indx].cost += 25000; - break; - - case 3: - case 11: - t_list[indx].flags |= 0x01004000; - strcat(t_list[indx].name, " (SM)"); - bm__add_tohit(4, 4, 1, indx, &r1); - bm__add_todam(4, 4, 1, indx, &r2); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - t_list[indx].cost += 15000; - break; - - case 4: - case 12: - t_list[indx].flags |= 0x00002000; - strcat(t_list[indx].name, " (SD)"); - bm__add_tohit(5, 5, 1, indx, &r1); - bm__add_todam(5, 5, 1, indx, &r2); - bm__add_toac(10, 1, 1, indx, &r4); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - t_list[indx].cost += 5000 * r4; - t_list[indx].cost += 15000; - break; - - case 5: - case 13: - t_list[indx].flags |= 0x01008000; - strcat(t_list[indx].name, " (SE)"); - bm__add_tohit(4, 4, 1, indx, &r1); - bm__add_todam(4, 4, 1, indx, &r2); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - t_list[indx].cost += 15000; - break; - - case 6: - case 14: - t_list[indx].flags |= 0x01010000; - strcat(t_list[indx].name, " (SU)"); - bm__add_tohit(4, 4, 1, indx, &r1); - bm__add_todam(4, 4, 1, indx, &r2); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - t_list[indx].cost += 15000; - break; - - case 7: - case 15: - t_list[indx].flags |= 0x00040000; - strcat(t_list[indx].name, " (FT)"); - bm__add_tohit(4, 4, 1, indx, &r1); - bm__add_todam(4, 4, 1, indx, &r2); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - t_list[indx].cost += 15000; - break; - - case 8: - case 16: - t_list[indx].flags |= 0x00002000; - strcat(t_list[indx].name, " (SD)"); - bm__add_tohit(5, 5, 1, indx, &r1); - bm__add_todam(5, 5, 1, indx, &r2); - bm__add_toac(10, 1, 1, indx, &r4); - t_list[indx].cost += 1000 * r1 + 1000 * r2; - t_list[indx].cost += 5000 * r4; - t_list[indx].cost += 15000; - break; - - default: - break; - } - break; - - case pick_or_shovel: - bm__add_p1(0, 3, 3, indx, &r5); - bm__add_tohit(4, 4, 1, indx, &r1); - bm__add_todam(4, 4, 1, indx, &r2); - t_list[indx].cost += 1000 * r1 + 1000 * r2 + 1000 * r5; - t_list[indx].cost += 15000; - break; - - case gloves_and_gauntlets: - switch (randint(2)) { - case 1: - t_list[indx].flags |= 0x00800000; - strcat(t_list[indx].name, " of Free Action"); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 1000 * r3 + 1000 * r4; - t_list[indx].cost += 15000; - break; - - case 2: - strcat(t_list[indx].name, " of Slaying"); - bm__add_tohit(6, 6, 1, indx, &r1); - bm__add_todam(6, 6, 1, indx, &r2); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 5000 * r1 + 6000 * r2; - t_list[indx].cost += 1000 * r3 + 1000 * r4; - t_list[indx].cost += 15000; - break; - - default: - break; - } - break; - - case cloak: - switch (randint(2)) { - case 1: - strcat(t_list[indx].name, " of Protection"); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - case 2: - t_list[indx].flags |= 0x00000100; - strcat(t_list[indx].name, " of Stealth (%P1)"); - bm__add_p1(0, 2, 2, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5 + 5000 * r3 + 5000 * r4; - break; - - default: - break; - } - break; - - case helm: - switch (t_list[indx].subval) { - case 1: - case 2: - case 3: - case 4: - case 5: - switch (randint(3)) { - case 1: - t_list[indx].flags |= 0x00000008; - strcat(t_list[indx].name, " of Intelligence"); - bm__add_p1(0, 2, 2, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5; - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - case 2: - t_list[indx].flags |= 0x00000010; - strcat(t_list[indx].name, " of Wisdom"); - bm__add_p1(0, 2, 2, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5; - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - case 3: - t_list[indx].flags |= 0x40000000; - strcat(t_list[indx].name, " of Infra-Vision"); - bm__add_p1(0, 4, 4, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5; - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - default: - break; - } - break; - - case 6: - case 7: - case 8: - switch (randint(6)) { - case 1: - t_list[indx].flags |= 0x00800007; - strcat(t_list[indx].name, " of Might"); - bm__add_p1(0, 4, 4, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5; - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - case 2: - t_list[indx].flags |= 0x00000030; - strcat(t_list[indx].name, " of Lordliness"); - bm__add_p1(0, 4, 4, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5; - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - case 3: - t_list[indx].flags |= 0x01380008; - strcat(t_list[indx].name, " of the Magi"); - bm__add_p1(0, 4, 4, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5; - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - case 4: - t_list[indx].flags |= 0x00000020; - strcat(t_list[indx].name, " of Beauty"); - bm__add_p1(0, 4, 4, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5; - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - case 5: - t_list[indx].flags |= 0x01000040; - strcat(t_list[indx].name, " of Seeing"); - bm__add_p1(0, 4, 4, indx, &r5); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r5; - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - case 6: - t_list[indx].flags |= 0x00000800; - strcat(t_list[indx].name, " of Regeneration"); - bm__add_ac(4, 4, 1, indx, &r3); - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 5000 * r3 + 5000 * r4; - break; - - default: - break; - } - break; - - default: - break; - }; - break; - case shield: - case hard_armor: - switch (randint(10)) { - case 1: - case 6: - t_list[indx].flags |= 0x02380000; - strcat(t_list[indx].name, " (R)"); - bm__add_toac(8, 8, 1, indx, &r4); - t_list[indx].cost += 10000 * r4; - t_list[indx].cost += 50000; - break; - - case 2: - case 7: - t_list[indx].flags |= 0x00100000; - strcat(t_list[indx].name, " (RA)"); - bm__add_toac(8, 8, 1, indx, &r4); - t_list[indx].cost += 10000 * r4; - t_list[indx].cost += 40000; - break; - - case 3: - case 8: - t_list[indx].flags |= 0x00080000; - strcat(t_list[indx].name, " (RF)"); - bm__add_toac(8, 8, 1, indx, &r4); - t_list[indx].cost += 10000 * r4; - t_list[indx].cost += 40000; - break; - - case 4: - case 9: - t_list[indx].flags |= 0x00200000; - strcat(t_list[indx].name, " (RC)"); - bm__add_toac(8, 8, 1, indx, &r4); - t_list[indx].cost += 10000 * r4; - t_list[indx].cost += 40000; - break; - - case 5: - case 10: - t_list[indx].flags |= 0x02000000; - strcat(t_list[indx].name, " (RL)"); - bm__add_toac(8, 8, 1, indx, &r4); - t_list[indx].cost += 10000 * r4; - t_list[indx].cost += 30000; - break; - - default: - break; - } - break; - - case amulet: - switch (t_list[indx].subval) { - case 1: - case 2: - bm__add_p1(0, 2, 2, indx, &r5); - t_list[indx].cost += 10000 * r5; - break; - - case 3: - bm__add_p1(8, 15, 15, indx, &r5); - t_list[indx].cost += 10000 * r5; - break; - - case 5: - bm__add_toac(4, 4, 0, indx, &r4); - t_list[indx].cost += 10000 * r4; - break; - - default: - break; - } - break; - - case ring: - switch (t_list[indx].subval) { - case 1: - case 2: - case 3: - case 4: /*{Gain stat}*/ - bm__add_p1(0, 2, 2, indx, &r5); - t_list[indx].cost += 10000 * r5; - break; - - case 7: /*{Speed}*/ - bm__add_p1(1, 2, 1, indx, &r5); - t_list[indx].cost += 500000 * r5; - break; - - case 8: /*{Searching}*/ - bm__add_p1(8, 15, 15, indx, &r5); - t_list[indx].cost += 10000 * r5; - break; - - case 10: - case 13: - case 26: /*{Slow Digestion, Feather-Falling, See-Invis}*/ - bm__add_toac(2, 2, 1, indx, &r4); - t_list[indx].cost += 10000 * r4; - break; - - case 17: - case 18: - case 19: /*{Lordly Protection}*/ - bm__add_toac(10, 8, 5, indx, &r4); - t_list[indx].cost += 10000 * r4; - break; - - case 22: /*{Increase Damage}*/ - bm__add_todam(3, 3, 3, indx, &r2); - t_list[indx].cost += 10000 * r2; - break; - - case 23: /*{Increase To-hit}*/ - bm__add_tohit(3, 3, 3, indx, &r1); - t_list[indx].cost += 10000 * r1; - break; - - case 24: /*{Protection}*/ - bm__add_toac(4, 4, 1, indx, &r4); - t_list[indx].cost += 10000 * r4; - break; - - case 33: /*{Slaying}*/ - bm__add_tohit(3, 3, 3, indx, &r1); - bm__add_todam(3, 3, 3, indx, &r2); - t_list[indx].cost += 10000 * r2 + 10000 * r1; - break; - - default: - break; - } - break; - - case staff: - switch (t_list[indx].subval) { - case 1: - bm__add_p1_rods(32, 20, 12, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 2: - bm__add_p1_rods(14, 8, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 3: - bm__add_p1_rods(11, 5, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 4: - bm__add_p1_rods(32, 20, 12, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 5: - bm__add_p1_rods(21, 15, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 6: - bm__add_p1_rods(9, 4, 5, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 7: - bm__add_p1_rods(8, 5, 3, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 8: - bm__add_p1_rods(4, 3, 1, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 9: - bm__add_p1_rods(4, 3, 1, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 10: - bm__add_p1_rods(4, 3, 1, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 11: - bm__add_p1_rods(11, 5, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 13: - bm__add_p1_rods(11, 5, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 14: - bm__add_p1_rods(11, 5, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 16: - bm__add_p1_rods(22, 10, 12, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 17: - bm__add_p1_rods(7, 3, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 19: - bm__add_p1_rods(11, 5, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 20: - bm__add_p1_rods(7, 3, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 21: - bm__add_p1_rods(22, 10, 12, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 22: - bm__add_p1_rods(7, 3, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 23: - bm__add_p1_rods(7, 3, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 24: - bm__add_p1_rods(7, 3, 1, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - default: - break; - } - break; - - case wand: - switch (t_list[indx].subval) { - case 1: - bm__add_p1_rods(16, 10, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 2: - bm__add_p1_rods(14, 8, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 3: - bm__add_p1_rods(11, 5, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 4: - bm__add_p1_rods(14, 8, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 5: - bm__add_p1_rods(7, 4, 3, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 6: - bm__add_p1_rods(14, 8, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 9: - bm__add_p1_rods(16, 10, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 10: - bm__add_p1_rods(18, 12, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 11: - bm__add_p1_rods(22, 10, 12, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 12: - bm__add_p1_rods(6, 3, 3, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 13: - bm__add_p1_rods(14, 8, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 14: - bm__add_p1_rods(16, 10, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 15: - bm__add_p1_rods(8, 5, 3, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 16: - bm__add_p1_rods(8, 5, 3, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 17: - bm__add_p1_rods(11, 5, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 18: - bm__add_p1_rods(9, 5, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 19: - bm__add_p1_rods(12, 8, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 20: - bm__add_p1_rods(12, 8, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 21: - bm__add_p1_rods(12, 8, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 22: - bm__add_p1_rods(36, 24, 12, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 23: - bm__add_p1_rods(12, 8, 4, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - case 24: - bm__add_p1_rods(16, 10, 6, indx, &r5); - t_list[indx].cost += 5000 * r5; - break; - - default: - break; - } - break; - - default: - break; - } - - /* - scost = -t_list[indx].cost; - insert_num(t_list[indx].name,"%P1",t_list[indx].p1,true); - insert_num(t_list[indx].name,"%P2",t_list[indx].tohit,true); - insert_num(t_list[indx].name,"%P3",t_list[indx].todam,true); - insert_num(t_list[indx].name,"%P4",t_list[indx].toac,true); - insert_num(t_list[indx].name,"%P5",t_list[indx].p1,false); - insert_num(t_list[indx].name,"%P6",t_list[indx].ac,false); - */ -} - -#if 0 -extern void store_carry( long store_num, long *ipos); - -/*{Add Black Market items to the inventory}*/ - -void do_black_market() -{ - long indx,iptr,inven_num; - - inven_num = 0; - store[S_BLACK_MARKET].store_ctr = 0; - /*while (inven_num < STORE_MIN_INVEN) { */ - inven_num = 5 + randint(STORE_INVEN_MAX); - /*} */ - if (inven_num > STORE_INVEN_MAX) { - inven_num = STORE_INVEN_MAX; - } - for (indx = 1; indx <= inven_num; indx++) { - /*with store[S_BLACK_MARKET].store_inven[indx] do; */ - iptr = randint(BLK_MKT_MAX); - BMI.sitem = blk_mkt_init[iptr]; - soup_up_black_market(indx); - inventory[inven_max] = BMI.sitem; - store_carry(S_BLACK_MARKET,iptr); - } - - for (indx = inven_num; indx <= STORE_INVEN_MAX; indx++) { - /*with store[S_BLACK_MARKET].store_inven[indx] do; */ - BMI.sitem = blank_treasure; - } - - store[S_BLACK_MARKET].store_ctr--; -} - -void Opusii_vomit(long percentage) -{ - if (randint(100) < percentage) { - /*with player_flags do; */ - (player_flags).foodc -= 500; - (player_flags).paralysis = 4; - msg_print("You feel your insides heave!"); - } -} -#endif - -/* END FILE store.c */ diff --git a/src/blow.c b/src/blow.c index 9d998851..010cb42f 100644 --- a/src/blow.c +++ b/src/blow.c @@ -261,7 +261,6 @@ static void b__misc_effects(long effect, boolean *idented, break; case 5: /*{Cross}*/ - strcat(item_ptr->data.name, "(Empty)"); msg_print("You free a Djinni from the bottle!"); msg_print("He grants you a wish..."); msg_print("'I will raise one of your stats by two...'"); @@ -285,7 +284,6 @@ static void b__misc_effects(long effect, boolean *idented, summon_demon(&x, &y); } player_flags.paralysis += 2; - strcat(item_ptr->data.name, "(Empty)"); ident = true; break; @@ -540,7 +538,7 @@ void blow() { } if (ident) { - identify(&(inven_temp.data)); + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); } if (inven_temp.data.flags != 0) { /* with player_do; */ diff --git a/src/constants.h b/src/constants.h index 50a5d1d3..30e6b18a 100644 --- a/src/constants.h +++ b/src/constants.h @@ -173,69 +173,6 @@ #define Equipment_light (Equipment_cloak + 1) /* 12 */ #define Equipment_secondary (Equipment_light + 1) /* 13 */ -/* .tval constants -DCJ- */ -#define miscellaneous_object 1 -#define chest 2 -#define misc_usable 3 -#define valuable_jewelry 4 -#define valuable_gems 5 -#define bag_or_sack 6 -#define valuable_gems_wear 7 -#define sling_ammo 10 -#define bolt 11 -#define arrow 12 -#define spike 13 -#define lamp_or_torch 15 -#define bow_crossbow_or_sling 20 -#define hafted_weapon 21 -#define pole_arm 22 -#define dagger 23 -#define sword 24 -#define pick_or_shovel 25 -#define maul 26 -#define gem_helm 29 -#define boots 30 -#define gloves_and_gauntlets 31 -#define cloak 32 -#define helm 33 -#define shield 34 -#define hard_armor 35 -#define soft_armor 36 -#define bracers 37 -#define belt 38 -#define amulet 40 -#define ring 45 -#define staff 55 -#define rod 60 -#define wand 65 -#define scroll1 70 -#define scroll2 71 -#define potion1 75 -#define potion2 76 -#define flask_of_oil 77 -#define Food 80 -#define junk_food 81 -#define chime 85 -#define horn 86 -#define magic_book 90 -#define prayer_book 91 -#define instrument 92 /* Not in use */ -#define song_book 93 -#define lodging_at_inn 95 -#define valuable_metal 100 /* look in detect_item for limit */ -#define unseen_trap 101 -#define seen_trap 102 -#define rubble 103 -#define open_door 104 -#define closed_door 105 -#define up_staircase 107 -#define down_staircase 108 -#define secret_door 109 -#define entrance_to_store 110 -#define up_steep_staircase 111 -#define down_steep_staircase 112 -#define whirlpool 113 - /* fields in py.flags.status */ #define IS_HUNGERY 0x00000001 #define IS_WEAK 0x00000002 diff --git a/src/constants.rs b/src/constants.rs index ad11edd1..8990e042 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,6 +1,6 @@ pub static SAVE_FOLDER: &'static str = "save"; pub static DATA_FOLDER: &'static str = "data"; -pub static OMORIA_VERSION: &'static str = "5.1.1-alpha"; +pub static OMORIA_VERSION: &'static str = "5.2.0-alpha"; pub static IMORIA_VERSION: &'static str = "4.85.22"; // Number of Cave tiles on y-axis diff --git a/src/creature.c b/src/creature.c index e7668976..deb4f56f 100644 --- a/src/creature.c +++ b/src/creature.c @@ -518,7 +518,7 @@ void c__apply_attack(long monptr, long atype, char ddesc[82], char *damstr) { boolean flag; treas_rec *item_ptr; obj_set food_stuffs = {Food, 0}; - obj_set staff_rod_or_wand = {staff, rod, wand, 0}; + obj_set staff_or_wand = {staff, wand, 0}; ENTER(("c__apply_attack", "c")); @@ -813,7 +813,7 @@ void c__apply_attack(long monptr, long atype, char ddesc[82], char *damstr) { } i4 = level; /* with item_ptr^.data do; */ - if (is_in(item_ptr->data.tval, staff_rod_or_wand)) { + if (is_in(item_ptr->data.tval, staff_or_wand)) { if (item_ptr->data.p1 > 0) { m_list[monptr].hp += i4 * item_ptr->data.p1; item_ptr->data.p1 = 0; @@ -886,9 +886,9 @@ void c__make_attack(long monptr) { } else { sprintf(ddesc, "& %s", c_list[m_list[monptr].mptr].name); } - strcpy(inven_temp.data.name, ddesc); + //strcpy(inven_temp.data.name, ddesc); inven_temp.data.number = 1; - objdes(ddesc, &inven_temp, true); + //objdes(ddesc, &inven_temp, true); strcpy(died_from, ddesc); /*{ End DIED_FROM }*/ @@ -1015,7 +1015,7 @@ boolean c__make_move(long monptr, mm_type mm, long *hear_count) { tflag = true; if (cave[newy][newx].fm) { if (los(char_row, char_col, newy, newx)) { - t_list[cave[newy][newx].tptr] = door_list[DL_OPEN]; + t_list[cave[newy][newx].tptr] = door_open; cave[newy][newx].fopen = true; lite_spot(newy, newx); tflag = false; @@ -1040,7 +1040,7 @@ boolean c__make_move(long monptr, mm_type mm, long *hear_count) { tflag = true; if (cave[newy][newx].fm) { if (los(char_row, char_col, newy, newx)) { - t_list[cave[newy][newx].tptr] = door_list[DL_OPEN]; + t_list[cave[newy][newx].tptr] = door_open; cave[newy][newx].fopen = true; lite_spot(newy, newx); tflag = false; @@ -1062,7 +1062,7 @@ boolean c__make_move(long monptr, mm_type mm, long *hear_count) { tflag = true; if (cave[newy][newx].fm) { if (los(char_row, char_col, newy, newx)) { - t_list[cave[newy][newx].tptr] = door_list[DL_OPEN]; + t_list[cave[newy][newx].tptr] = door_open; t_list[cave[newy][newx].tptr].p1 = randint(2) - 1; cave[newy][newx].fopen = true; lite_spot(newy, newx); @@ -1320,9 +1320,9 @@ boolean c__cast_spell(long monptr, boolean *took_turn) { } else { sprintf(ddesc, "& %s", c_list[m_list[monptr].mptr].name); } - strcpy(inven_temp.data.name, ddesc); + //strcpy(inven_temp.data.name, ddesc); inven_temp.data.number = 1; - objdes(ddesc, &inven_temp, true); + //objdes(ddesc, &inven_temp, true); /*{ End DIED_FROM }*/ /*{ Extract all possible spells into spell_choice }*/ diff --git a/src/desc.c b/src/desc.c index 01ddaf45..7493d7f1 100644 --- a/src/desc.c +++ b/src/desc.c @@ -17,208 +17,6 @@ #include "types.h" #include "variables.h" -void rantitle(char *title) { - /*{ Return random title }*/ - - long i1, i2, i3, i4; - - i3 = randint(2) + 1; /* two or three words */ - strcpy(title, "Titled \""); - - for (i1 = 0; i1 < i3; i1++) { - i4 = randint(2); /* one or two syllables each */ - for (i2 = 0; i2 < i4; i2++) { - strcat(title, syllables[randint(MAX_SYLLABLES) - 1]); - } - - if (i1 != i3 - 1) { - strcat(title, " "); - } - } - strcat(title, "\""); -} - -void identify(treasure_type *item) { - /*{ Something has been identified }*/ - - - if (strstr(item->name, "|") == NULL) - return; - - for (long i = 0; i < MAX_TALLOC; i++) { - if (t_list[i].tval == item->tval && t_list[i].subval == item->subval) { - unquote(t_list[i].name); - known1(t_list[i].name); - } - } - - for (long i = Equipment_min; i <= Equipment_secondary; i++) { - if (equipment[i].tval == item->tval && equipment[i].subval == item->subval) { - unquote(equipment[i].name); - known1(equipment[i].name); - } - } - - for (treas_rec *curse = inventory_list; curse != NULL; curse = curse->next) { - if (curse->data.tval == item->tval && curse->data.subval == item->subval) { - unquote(curse->data.name); - known1(curse->data.name); - } - } -} - -void known1(char *object_str) { - /*{ Remove 'Secret' symbol for identity of object - * }*/ - - insert_str(object_str, "|", ""); -} - -void known2(char *object_str) { - /*{ Remove 'Secret' symbol for identity of pluses - * }*/ - - insert_str(object_str, "^", ""); -} - -void unquote(char *object_str) { - /* { Return string without quoted portion }*/ - - long pos0, pos1, pos2, olen; - char str1[82], str2[82]; - - pos0 = pindex(object_str, '"'); - if (pos0 > 0) { - pos1 = pindex(object_str, '~'); - pos2 = pindex(object_str, '|'); - olen = strlen(object_str); - strncpy(str1, object_str, pos1); - str1[pos1] = 0; - strncpy(str2, &(object_str[pos2]), olen - pos2); - str2[olen - pos2] = 0; - sprintf(object_str, "%s%s", str1, str2); - } -} - -/** - * objdes() - Returns a description of item for inventory - * @out_val: Where to put the return string - * @ptr: Pointer to the object to describe - * @pref: ??? - */ -void objdes(char *out_val, treas_rec *ptr, boolean pref) { - char *cpos; - char tmp_val[82]; - - ENTER(("objdes", "i")); - - strcpy(tmp_val, ptr->data.name); - -#if DO_DEBUG - if (do_debug_objdes) { - MSG(("obj start: >%s<\n", tmp_val)); - } -#endif - - cpos = strstr(tmp_val, "|"); - if (cpos != NULL) { - *cpos = '\0'; - } - -#if DO_DEBUG - if (do_debug_objdes) { - MSG(("obj thmp1: >%s<\n", tmp_val)); - } -#endif - - cpos = strstr(tmp_val, "^"); - if (cpos != NULL) { - *cpos = '\0'; - } - -#if DO_DEBUG - if (do_debug_objdes) { - MSG(("obj thmp2: >%s<\n", tmp_val)); - } -#endif - - if (!pref) { - cpos = strstr(tmp_val, " ("); - if (cpos != NULL) { - *cpos = '\0'; - } - } - -#if DO_DEBUG - if (do_debug_objdes) { - MSG(("obj thmp3: >%s<\n", tmp_val)); - } -#endif - - insert_str(tmp_val, "%P0", ptr->data.damage); - insert_num(tmp_val, "%P1", ptr->data.p1, true); - insert_num(tmp_val, "%P2", ptr->data.tohit, true); - insert_num(tmp_val, "%P3", ptr->data.todam, true); - insert_num(tmp_val, "%P4", ptr->data.toac, true); - insert_num(tmp_val, "%P5", ptr->data.p1, false); - insert_num(tmp_val, "%P6", ptr->data.ac, false); - -#if DO_DEBUG - if (do_debug_objdes) { - MSG(("obj thmp4: >%s<\n", tmp_val)); - } -#endif - - if (ptr->data.number != 1) { - insert_str(tmp_val, "ch~", "ches"); - insert_str(tmp_val, "y~", "ies"); - insert_str(tmp_val, "~", "s"); - } else { - insert_str(tmp_val, "~", ""); - } - -#if DO_DEBUG - if (do_debug_objdes) { - MSG(("obj thmp5: >%s<\n", tmp_val)); - } -#endif - - if (pref) { - if (strstr(tmp_val, "&") != NULL) { - insert_str(tmp_val, "&", ""); - - if (ptr->data.number > 1) { - sprintf(out_val, "%d%s", ptr->data.number, tmp_val); - } else if (ptr->data.number < 1) { - sprintf(out_val, "no more%s", tmp_val); - } else if (is_vowel(tmp_val[1])) { - sprintf(out_val, "an%s", tmp_val); - } else { - sprintf(out_val, "a%s", tmp_val); - } - - } else { - if (ptr->data.number > 0) { - strcpy(out_val, tmp_val); - } else { - sprintf(out_val, "no more %s", tmp_val); - } - } - - } else { - insert_str(tmp_val, "& ", ""); - strcpy(out_val, tmp_val); - } - -#if DO_DEBUG - if (do_debug_objdes) { - MSG(("obj final: >%s<\n", out_val)); - } -#endif - - LEAVE("objdes", "i"); -} - char *bag_descrip(treas_rec *bag, char result[134]) /* was func */ { /*{ Return description about the contents of a bag -DMF- }*/ diff --git a/src/dungeon.c b/src/dungeon.c index 09a20529..b377135e 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -394,7 +394,7 @@ static void d__look() { } else if (t_list[cave[y][x].tptr].tval != unseen_trap) { inven_temp.data = t_list[cave[y][x].tptr]; inven_temp.data.number = 1; - objdes(out_val, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "You see %s.", out_val); msg_print(out_val2); flag = true; @@ -1415,7 +1415,7 @@ static void d__bash() { labs(t_list[cave[y][x].tptr].p1) + 150)) { msg_print("You smash into the door! " "The door crashes open!"); - t_list[cave[y][x].tptr] = door_list[DL_OPEN]; + t_list[cave[y][x].tptr] = door_open; t_list[cave[y][x].tptr].p1 = 1; cave[y][x].fopen = true; lite_spot(y, x); @@ -1430,7 +1430,6 @@ static void d__bash() { if (randint(10) == 1) { msg_print("You have destroyed the chest..."); msg_print("and its contents!"); - strcpy(t_list[cave[y][x].tptr].name, "& ruined chest"); t_list[cave[y][x].tptr].flags = 0; } else if ((0x00000001 & t_list[cave[y][x].tptr].flags) != 0) { if (randint(10) == 1) { @@ -1510,7 +1509,6 @@ static void d__openobject() { long y, x, tmp, temp_dun_level; boolean flag; - char *tmpc; y = char_row; x = char_col; @@ -1547,7 +1545,7 @@ static void d__openobject() { } if (t_list[cave[y][x].tptr].p1 == 0) { - t_list[cave[y][x].tptr] = door_list[DL_OPEN]; + t_list[cave[y][x].tptr] = door_open; cave[y][x].fopen = true; lite_spot(y, x); } @@ -1582,12 +1580,6 @@ static void d__openobject() { if (flag) { t_list[cave[y][x].tptr].flags &= 0xFFFFFFFE; /* unlock */ - tmpc = strstr(t_list[cave[y][x].tptr].name, " ("); - if (tmpc != NULL) { - *tmpc = 0; - } - strcat(t_list[cave[y][x].tptr].name, " (Empty)"); - known2(t_list[cave[y][x].tptr].name); t_list[cave[y][x].tptr].cost = 0; } @@ -1667,7 +1659,7 @@ static void d__closeobject() { if (t_list[cave[y][x].tptr].tval == open_door) { if (cave[y][x].cptr == 0) { if (t_list[cave[y][x].tptr].p1 == 0) { - t_list[cave[y][x].tptr] = door_list[1]; + t_list[cave[y][x].tptr] = door_closed; cave[y][x].fopen = false; lite_spot(y, x); } else { @@ -1694,7 +1686,6 @@ static void d__disarm_trap() { long y, x, i1, tdir; long tot, t1, t2, t3, t4, t5; - char *tmpc; y = char_row; x = char_col; @@ -1740,32 +1731,20 @@ static void d__disarm_trap() { move_char(tdir); } } else if (i1 == 2) { /*{ Chest trap }*/ - /* with t_list[cave[y][x].tptr]. do; */ - if (strstr(t_list[cave[y][x].tptr].name, "^") != NULL) { - msg_print("I don't see a trap..."); - } else if ((0x000001F0 & t_list[cave[y][x].tptr].flags) != 0) { + if ((0x000001F0 & t_list[cave[y][x].tptr].flags) != 0) { if ((tot - t5) > randint(100)) { t_list[cave[y][x].tptr].flags &= 0xFFFFFE0F; - tmpc = strstr(t_list[cave[y][x].tptr].name, " ("); - if (tmpc != NULL) { - *tmpc = 0; - } - if ((0x00000001 & t_list[cave[y][x].tptr].flags) != 0) { - strcat(t_list[cave[y][x].tptr].name, " (Locked)"); - } else { - strcat(t_list[cave[y][x].tptr].name, " (Disarmed)"); - } - msg_print("You have disarmed " - "the chest."); - known2(t_list[cave[y][x].tptr].name); + msg_print("You have disarmed the chest."); + treasure_type *treas = &t_list[cave[y][x].tptr]; + set_type_identified(treas->tval, treas->subval, true); + treas->identified = true; C_player_add_exp(t5); prt_stat_block(); } else if (randint(tot) > 5) { - msg_print("You failed to " - "disarm the chest."); + msg_print("You failed to disarm the chest."); } else { msg_print("You set a trap off!"); - known2(t_list[cave[y][x].tptr].name); + t_list[cave[y][x].tptr].identified = true; d__chest_trap(y, x); } } else { @@ -1959,7 +1938,7 @@ static void d__drop() { inven_drop(com_ptr, char_row, char_col, false); } prt_stat_block(); - objdes(out_val, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "Dropped %s.", out_val); msg_print(out_val2); reset_flag = false; @@ -2704,7 +2683,7 @@ void py_bonuses(treasure_type *tobj, long factor) { player_ptohit += equipment[i1].tohit; player_ptodam += equipment[i1].todam; player_ptoac += equipment[i1].toac; - if (strstr(equipment[i1].name, "^") == NULL) { + if (equipment[i1].identified) { player_dis_th += equipment[i1].tohit; player_dis_td += equipment[i1].todam; player_dis_tac += equipment[i1].toac; @@ -3015,7 +2994,7 @@ void carry(long y, long x) { } prt_stat_block(); - objdes(out_val, item_ptr, true); + C_item_name_generate_name(&inven_temp.data, out_val); if (money_flag) { @@ -3536,12 +3515,12 @@ boolean minus_ac(long typ_dam) { inven_temp.data = equipment[i2]; /* with equipment[i2] do; */ if ((equipment[i2].flags & typ_dam) != 0) { - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_str, "Your %s resists damage!", out_val); msg_print(out_str); return_value = true; } else if ((equipment[i2].ac + equipment[i2].toac) > 0) { - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_str, "Your %s is damaged!", out_val); msg_print(out_str); equipment[i2].toac--; @@ -3557,7 +3536,7 @@ void fire_dam(long dam, char kb_str[82]) { /*{ Burn the fool up... -RAK- }*/ obj_set things_that_burn = {arrow, - bow_crossbow_or_sling, + bow, crossbow, sling, hafted_weapon, pole_arm, maul, @@ -3566,8 +3545,7 @@ void fire_dam(long dam, char kb_str[82]) { cloak, soft_armor, staff, - scroll1, - scroll2, + Scroll, 0}; if (player_flags.fire_resist) { @@ -3590,7 +3568,7 @@ void fire_dam(long dam, char kb_str[82]) { void cold_dam(long dam, char kb_str[82]) { /*{ Freeze him to death... -RAK- }*/ - obj_set things_that_freeze = {potion1, potion2, 0}; + obj_set things_that_freeze = {potion, 0}; if (player_flags.cold_resist) { dam /= 3; @@ -3630,7 +3608,7 @@ void acid_dam(long dam, char kb_str[82]) { long flag = 0; obj_set things_that_dilute = { miscellaneous_object, chest, bolt, arrow, - bow_crossbow_or_sling, hafted_weapon, pole_arm, boots, + bow, crossbow, sling, hafted_weapon, pole_arm, boots, gloves_and_gauntlets, cloak, soft_armor, 0}; if (minus_ac(Resist_Acid_worn_bit)) { @@ -3832,8 +3810,10 @@ void search(long player_y, long player_x, long chance) { if (t_list[cave[y][x].tptr].tval == unseen_trap) { // Trap on floor + char tname[70]; char out_val[86]; - sprintf(out_val, "You have found %s.", t_list[cave[y][x].tptr].name); + C_item_name_generate_name(&t_list[cave[y][x].tptr], tname); + sprintf(out_val, "You have found %s.", tname); msg_print(out_val); change_trap(y, x); find_flag = false; @@ -3847,9 +3827,10 @@ void search(long player_y, long player_x, long chance) { } else if (t_list[cave[y][x].tptr].tval == chest) { if (t_list[cave[y][x].tptr].flags > 1) { - if (pindex(t_list[cave[y][x].tptr].name, '^') > 0) { + if (!t_list[cave[y][x].tptr].identified) { // Chest is trapped - known2(t_list[cave[y][x].tptr].name); + + t_list[cave[y][x].tptr].identified = true; msg_print("You have discovered a trap on the chest!"); } } @@ -4366,9 +4347,17 @@ boolean py_attack(long y, long x) { if (equipment[Equipment_primary].tval > 0) { i3 = damroll(equipment[Equipment_primary].damage); i3 = tot_dam(&equipment[Equipment_primary], i3, &c_list[a_mptr]); - is_sharp = - (equipment[Equipment_primary].tval != bow_crossbow_or_sling) && - ((equipment[Equipment_primary].flags2 & Sharp_worn_bit) != 0); + switch (equipment[Equipment_primary].tval) { + case bow: + case crossbow: + case sling: + is_sharp = false; + break; + + default: + is_sharp = equipment[Equipment_primary].flags2 & Sharp_worn_bit; + break; + } crit_mult = critical_blow(equipment[Equipment_primary].weight, tot_tohit, is_sharp, false); if (backstab_flag) { @@ -4440,7 +4429,7 @@ long tot_dam(treasure_type *item, long tdam, creature_type *monster) { /*{ Special damage due to magical abilities of object -RAK- }*/ obj_set stuff_that_goes_thump = { - sling_ammo, bolt, arrow, lamp_or_torch, bow_crossbow_or_sling, + sling_ammo, bolt, arrow, lamp_or_torch, bow, crossbow, sling, hafted_weapon, pole_arm, dagger, sword, maul, flask_of_oil, 0}; @@ -4594,7 +4583,7 @@ void desc_remain(treas_rec *item_ptr) { /* with inven_temp->data do; */ inven_temp.data.number--; - objdes(out_val, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "You have %s.", out_val); msg_print(out_val2); } @@ -4678,7 +4667,7 @@ void desc_charges(treas_rec *item_ptr) { char out_val[82]; - if (strstr(item_ptr->data.name, "^") == NULL) { + if (item_ptr->data.identified) { sprintf(out_val, "You have %ld charges remaining.", item_ptr->data.p1); msg_print(out_val); } diff --git a/src/dungeon.h b/src/dungeon.h index 5b061511..11e1e776 100644 --- a/src/dungeon.h +++ b/src/dungeon.h @@ -23,11 +23,6 @@ extern long i_summ_count; /* { Summon item count } */ #define DISPLAY_SIZE 20 #define MOO_DISPLAY_SIZE 18 -/* index stuff for door_list */ -#define DL_OPEN 0 -#define DL_CLOSED 1 -#define DL_SECRET 2 - #define ML(mmm) (m_list[(mmm)]) #define MY(mmm) (m_list[(mmm)].fy) #define MX(mmm) (m_list[(mmm)].fx) diff --git a/src/eat.c b/src/eat.c index 4d20f03e..26472abe 100644 --- a/src/eat.c +++ b/src/eat.c @@ -293,7 +293,7 @@ void eat() { boolean const identify_effect = __apply_food_effects(item_ptr); if (identify_effect) { - identify(&(item_ptr->data)); + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); } if (item_ptr->data.flags != 0 && item_ptr->data.level > 0) { diff --git a/src/equipment.rs b/src/equipment.rs index 670206e3..47b11096 100644 --- a/src/equipment.rs +++ b/src/equipment.rs @@ -1,4 +1,5 @@ use model::Item; +use logic::item_name; pub const EQUIP_MAX: usize = 15; @@ -75,6 +76,6 @@ pub fn get_name(slot: Slot) -> String { let item = unsafe { equipment[slot as usize] }; match item.tval { 0 => "".to_string(), - _ => item.equipment_name(), + _ => item_name::generate(&item), } } diff --git a/src/fighting_ranged.c b/src/fighting_ranged.c index 62575f9b..7986dd3e 100644 --- a/src/fighting_ranged.c +++ b/src/fighting_ranged.c @@ -165,9 +165,9 @@ static void __missile_hit_ground(treas_rec *missile, long y, long x) { lite_spot(place_missile_y, place_missile_x); } } else { - char out_val[82]; + char out_val[70]; + C_item_name_generate_name(&missile->data, out_val); char out_val2[120]; - objdes(out_val, missile, false); sprintf(out_val2, "The %s disappears.", out_val); msg_print(out_val2); } @@ -196,12 +196,14 @@ static boolean __missile_try_hit_creature(treas_rec *missile, return false; } - char missile_text_buf[82]; - char monster_name_buf[82]; - char text_buf[200]; + char missile_text_buf[70]; long monster_index = m_list[cave[y][x].cptr].mptr; - objdes(missile_text_buf, missile, FALSE); + C_item_name_generate_name(&missile->data, missile_text_buf); + + char monster_name_buf[82]; find_monster_name(monster_name_buf, cave[y][x].cptr, FALSE); + + char text_buf[200]; sprintf(text_buf, "The %s hits %s.", missile_text_buf, monster_name_buf); msg_print(text_buf); damage = tot_dam(&(missile->data), damage, &(c_list[monster_index])); @@ -302,30 +304,22 @@ static long __count_things_to_throw() { static uint8_t __calculate_ammo_type() { ENTER(("__calculate_ammo_type", "d")); - if (equipment[Equipment_primary].tval != bow_crossbow_or_sling) { - LEAVE("__calculate_ammo_type", "d"); - return 0; - } + switch (equipment[Equipment_primary].tval) { + case bow: + LEAVE("__calculate_ammo_type", "d"); + return arrow; - switch (equipment[Equipment_primary].p1) { - case 1: - LEAVE("__calculate_ammo_type", "d"); - return sling_ammo; + case crossbow: + LEAVE("__calculate_ammo_type", "d"); + return bolt; - case 2: - case 3: - case 4: - LEAVE("__calculate_ammo_type", "d"); - return arrow; + case sling: + LEAVE("__calculate_ammo_type", "d"); + return sling_ammo; - case 5: - case 6: - LEAVE("__calculate_ammo_type", "d"); - return bolt; - - default: - LEAVE("__calculate_ammo_type", "d"); - return 0; + default: + LEAVE("__calculate_ammo_type", "d"); + return 0; } } diff --git a/src/files.c b/src/files.c index aa3a2cf2..58aacde9 100644 --- a/src/files.c +++ b/src/files.c @@ -274,7 +274,7 @@ void file_character() { } i2++; inven_temp.data = equipment[i1]; - objdes(prt2, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, prt2); if ((inven_temp.data.flags2 & Insured_bit) == 0) { sprintf(out_val, " %c%s%s", (char)(i2 + 96), prt1, prt2); } else { @@ -307,7 +307,7 @@ void file_character() { (i1 / 50) + 1); } inven_temp.data = curse->data; - objdes(s1, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, s1); if (curse->is_in) { sprintf(prt1, " %s", s1); } else { @@ -466,10 +466,9 @@ void print_objects() { t_list[i2] = generate_item_for_dungeon_level(level); inven_temp.data = t_list[i2]; /* with inven_temp->data. do; */ - unquote(inven_temp.data.name); - known1(inven_temp.data.name); - known2(inven_temp.data.name); - objdes(tmp_str, &inven_temp, true); + set_type_identified(inven_temp.data.tval, inven_temp.data.subval, true); + inven_temp.data.identified = true; + C_item_name_generate_name(&inven_temp.data, tmp_str); fprintf(file1, "%s\n", tmp_str); } pusht(i2); diff --git a/src/identification.rs b/src/identification.rs new file mode 100644 index 00000000..634b798a --- /dev/null +++ b/src/identification.rs @@ -0,0 +1,38 @@ +use std::sync::RwLock; +use std::collections::HashMap; +use std::collections::hash_map::Entry; + +use model; + +pub type Data = HashMap>; + +lazy_static! { + static ref IDENTIFICATION: RwLock = RwLock::new(HashMap::new()); +} + +pub fn save() -> Data { + *IDENTIFICATION.try_read().unwrap() +} + +pub fn load(data: Data) { + *IDENTIFICATION.try_write().unwrap() = data +} + +pub fn is_item_type_identified(item_type: model::ItemType, subval: i64) -> bool { + if let Entry::Occupied(o) = (*IDENTIFICATION.try_read().unwrap()).entry(item_type) { + if let Entry::Occupied(p) = o.get().entry(subval) { + return *p.get(); + } + } + + false +} + +pub fn set_item_type_identified(item_type: model::ItemType, subval: i64, is_identified: bool) { + IDENTIFICATION.try_write().unwrap() + .entry(item_type) + .or_insert(HashMap::new()) + .entry(subval) + .and_modify(|val| *val = is_identified) + .or_insert(is_identified); +} diff --git a/src/identification_interop.rs b/src/identification_interop.rs new file mode 100644 index 00000000..41ef7fa8 --- /dev/null +++ b/src/identification_interop.rs @@ -0,0 +1,14 @@ +use libc; + +use debug; +use identification; + +#[no_mangle] +pub extern fn is_type_identified(item_type: libc::uint8_t, subval: libc::int64_t) -> libc::uint8_t { + identification::is_item_type_identified(item_type, subval) ? 255 : 0 +} + +#[no_mangle] +pub extern fn set_type_identified(item_type: libc::uint8_t, subval: libc::int64_t, is_identified: libc::uint8_t) { + identification::set_item_type_identified(item_type, subval, is_identified == 0 ? false : true); +} diff --git a/src/inven.c b/src/inven.c index a00e7661..6364a73a 100644 --- a/src/inven.c +++ b/src/inven.c @@ -241,9 +241,9 @@ long ic__display_inv(treas_rec *cur_display[], char prompt[82], if (cur_display[count] != start) { cur_display[count] = start; inven_temp.data = start->data; - objdes(out_val, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, out_val); if ((start->data.flags2 & Holding_bit) != 0) { - if (strstr(start->data.name, "|") == NULL) { + if (is_type_identified(start->data.tval, start->data.subval)) { bag_descrip(start, out_val3); strcat(out_val, out_val3); } @@ -491,7 +491,7 @@ void inv__equip_pos_string(char out_val[82], long equip_pos, long counter) { char tmp_buf[82]; inven_temp.data = equipment[equip_pos]; - objdes(tmp_buf, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, tmp_buf); sprintf(out_val, "%c%c%c%s%s", cur_insure(), (char)('a' + counter - 1), cur_char2(), ic__equip_print_prefix(equip_pos), tmp_buf); } @@ -529,7 +529,9 @@ treas_rec *ic__remove(long item_val, boolean show_message) { case sling_ammo: case bolt: case arrow: - case bow_crossbow_or_sling: + case bow: + case crossbow: + case sling: case hafted_weapon: case pole_arm: case sword: @@ -548,7 +550,7 @@ treas_rec *ic__remove(long item_val, boolean show_message) { break; } - objdes(prt2, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, prt2); sprintf(out_val, "%s%s", prt1, prt2); msg_print(out_val); } @@ -721,7 +723,7 @@ void ic__wear(treas_rec *cur_display[], long *cur_display_size, char prompt[82], { /* Filter item types before we show the list */ const obj_set wearables = {valuable_gems_wear, lamp_or_torch, - bow_crossbow_or_sling, + bow, crossbow, sling, hafted_weapon, pole_arm, dagger, @@ -741,8 +743,6 @@ void ic__wear(treas_rec *cur_display[], long *cur_display_size, char prompt[82], amulet, ring, 0, - 0, - 0, 0}; treas_rec *ptr; long count; @@ -774,7 +774,9 @@ void ic__wear(treas_rec *cur_display[], long *cur_display_size, char prompt[82], i1 = Equipment_light; break; - case bow_crossbow_or_sling: + case bow: + case crossbow: + case sling: case hafted_weapon: case pole_arm: case sword: @@ -847,7 +849,7 @@ void ic__wear(treas_rec *cur_display[], long *cur_display_size, char prompt[82], i1 == Equipment_primary ? "wielding" : "wearing"; char out_val_tmp[82]; inven_temp.data = equipment[i1]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); strcpy(out_val_tmp, out_val); sprintf(out_val, "The %s you are %s appears to be cursed", out_val_tmp, equip_way); @@ -890,7 +892,7 @@ void ic__wear(treas_rec *cur_display[], long *cur_display_size, char prompt[82], break; } inven_temp.data = equipment[i1]; - objdes(prt2, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, prt2); i2 = 0; i3 = Equipment_min - 1; do { /*{ Get the right letter of equipment }*/ @@ -959,8 +961,10 @@ void ic__stats(treas_rec *cur_display[], long *cur_display_size, prt("Level : ", 18, 1); prt("Blackmarket : ", 19, 1); prt("Insured : ", 20, 1); - prt(item_ptr->data.name, 1, 15); - objdes(out_val, item_ptr, true); + char name[70]; + C_item_name_generate_name(&item_ptr->data, name); + prt(name, 1, 15); + C_item_name_generate_name(&item_ptr->data, out_val); prt(out_val, 2, 15); sprintf(out_val, "%ld", (long)item_ptr->data.tval); prt(out_val, 3, 15); @@ -1002,7 +1006,9 @@ void ic__stats(treas_rec *cur_display[], long *cur_display_size, case lamp_or_torch: strcpy(out_val, "Lamp or torch"); break; - case bow_crossbow_or_sling: + case bow: + case crossbow: + case sling: strcpy(out_val, "Ranged weapon"); break; case hafted_weapon: @@ -1062,18 +1068,13 @@ void ic__stats(treas_rec *cur_display[], long *cur_display_size, case staff: strcpy(out_val, "Staff"); break; - case rod: - strcpy(out_val, "Rod"); - break; case wand: strcpy(out_val, "Wand"); break; - case scroll1: - case scroll2: + case Scroll: strcpy(out_val, "Scroll"); break; - case potion1: - case potion2: + case potion: strcpy(out_val, "Potion"); break; case flask_of_oil: @@ -1406,7 +1407,7 @@ void ic__switch_weapon(long *scr_state) { char prt1[82]; char prt2[200]; inven_temp.data = equipment[Equipment_primary]; - objdes(prt1, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, prt1); sprintf(prt2, "The %s you are wielding appears to be cursed.", prt1); msg_print(prt2); } else { @@ -1672,7 +1673,7 @@ char cur_char1() { return_value = ')'; /*{ Not cursed... }*/ } else if ((Known_cursed_bit & inven_temp.data.flags2) != 0) { return_value = '*'; /*{ Cursed and detected by spell }*/ - } else if (pindex(inven_temp.data.name, '^') > 0) { + } else if (!inven_temp.data.identified) { return_value = ')'; /*{ Cursed, but not identified }*/ } else { return_value = '*'; /*{ Cursed and identified... }*/ diff --git a/src/item_template/ammunition.rs b/src/item_template/ammunition.rs index cfa46926..0557fd89 100644 --- a/src/item_template/ammunition.rs +++ b/src/item_template/ammunition.rs @@ -22,18 +22,19 @@ impl AmmunitionTemplate { pub fn iter() -> impl Iterator> { AmmunitionTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for AmmunitionTemplate { - fn name(&self) -> &str { - match self { - AmmunitionTemplate::Arrow => "& Arrow~^ (%P2,%P3)", - AmmunitionTemplate::Bolt => "& Bolt~^ (%P2,%P3)", - AmmunitionTemplate::RoundedPebble => "& Rounded Pebble~^ (%P2,%P3)", - AmmunitionTemplate::IronShot => "& Iron Shot~^ (%P2,%P3)", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(AmmunitionTemplate::Arrow), + 2 => Box::new(AmmunitionTemplate::Bolt), + 3 => Box::new(AmmunitionTemplate::RoundedPebble), + 4 => Box::new(AmmunitionTemplate::IronShot), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for AmmunitionTemplate { fn item_type(&self) -> model::ItemType { match self { AmmunitionTemplate::Arrow => model::ItemType::Arrow, @@ -64,7 +65,14 @@ impl item_template::ItemTemplate for AmmunitionTemplate { } } - fn subtype(&self) -> i64 { 1 } + fn subtype(&self) -> i64 { + match self { + AmmunitionTemplate::Arrow => 1, + AmmunitionTemplate::Bolt => 2, + AmmunitionTemplate::RoundedPebble => 3, + AmmunitionTemplate::IronShot => 4, + } + } fn weight(&self) -> u16 { match self { diff --git a/src/item_template/amulet.rs b/src/item_template/amulet.rs index 795bc427..106b2988 100644 --- a/src/item_template/amulet.rs +++ b/src/item_template/amulet.rs @@ -40,27 +40,28 @@ impl AmuletTemplate { pub fn iter() -> impl Iterator> { AmuletTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for AmuletTemplate { - fn name(&self) -> &str { - match self { - AmuletTemplate::AmuletOfAdornment1 => "& Amulet| of Adornment^", - AmuletTemplate::AmuletOfAdornment2 => "& Amulet| of Adornment^", - AmuletTemplate::AmuletOfWisdom => "& Amulet| of Wisdom^ (%P1)", - AmuletTemplate::AmuletOfCharisma => "& Amulet| of Charisma^ (%P1)", - AmuletTemplate::AmuletOfSearching => "& Amulet| of Searching^ (%P1)", - AmuletTemplate::AmuletOfTeleportation => "& Amulet| of Teleportation^", - AmuletTemplate::AmuletOfSlowDigestion => "& Amulet| of Slow Digestion^", - AmuletTemplate::AmuletOfResistAcid => "& Amulet| of Resist Acid^", - AmuletTemplate::AmuletOfTheMagi => "& Amulet| of the Magi^", - AmuletTemplate::AmuletOfDoom => "& Amulet| of Doom^", - AmuletTemplate::SilverNecklace => "& Silver Necklace~^", - AmuletTemplate::GoldNecklace => "& Gold Necklace~^", - AmuletTemplate::MithrilNecklace => "& Mithril Necklace~^", + pub fn from(subval: i64) -> Box { + match subval { + 11 => Box::new(AmuletTemplate::AmuletOfAdornment1), + 12 => Box::new(AmuletTemplate::AmuletOfAdornment2), + 5 => Box::new(AmuletTemplate::AmuletOfWisdom), + 6 => Box::new(AmuletTemplate::AmuletOfCharisma), + 7 => Box::new(AmuletTemplate::AmuletOfSearching), + 8 => Box::new(AmuletTemplate::AmuletOfTeleportation), + 9 => Box::new(AmuletTemplate::AmuletOfSlowDigestion), + 10 => Box::new(AmuletTemplate::AmuletOfResistAcid), + 13 => Box::new(AmuletTemplate::AmuletOfTheMagi), + 14 => Box::new(AmuletTemplate::AmuletOfDoom), + 30 => Box::new(AmuletTemplate::SilverNecklace), + 40 => Box::new(AmuletTemplate::GoldNecklace), + 50 => Box::new(AmuletTemplate::MithrilNecklace), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for AmuletTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Amulet } fn flags1(&self) -> u64 { 0 } diff --git a/src/item_template/armor.rs b/src/item_template/armor.rs deleted file mode 100644 index a0c9c64e..00000000 --- a/src/item_template/armor.rs +++ /dev/null @@ -1,405 +0,0 @@ -use model; -use item_template; - -#[derive(Copy, Clone, Eq, PartialEq, Hash)] -pub enum ArmorTemplate { - AugmentedChainMail, - BarChainMail, - BronzePlateMail, - ChainMail, - CoolSetOfThreads, - DemonhideArmor, - DoubleChainMail, - DuskShroud, - ElvenChainMail, - FilthyNagaHideArmor, - FilthyRags, - FullPlateArmor, - HardLeatherArmor, - HardLeatherRingMail, - HardStuddedLeather, - LacqueredPlate, - LaminatedArmor, - LeatherBrigantineArmor, - LeatherScaleMail, - MetalBrigandineArmor, - MetalLamellarArmor, - MetalScaleMail, - MithrilChainMail, - MithrilPlateArmor, - PartialPlateArmor, - Robe, - RustyChainMail, - SoftLeatherArmor, - SoftLeatherRingMail, - SoftStuddedLeather, - StonePlateArmor, - WovenCordArmor, - WyrmhideArmor, -} - - -impl ArmorTemplate { - pub fn vec() -> Vec> { - vec![ - Box::new(ArmorTemplate::AugmentedChainMail), - Box::new(ArmorTemplate::BarChainMail), - Box::new(ArmorTemplate::BronzePlateMail), - Box::new(ArmorTemplate::ChainMail), - Box::new(ArmorTemplate::CoolSetOfThreads), - Box::new(ArmorTemplate::DemonhideArmor), - Box::new(ArmorTemplate::DoubleChainMail), - Box::new(ArmorTemplate::DuskShroud), - Box::new(ArmorTemplate::ElvenChainMail), - Box::new(ArmorTemplate::FilthyNagaHideArmor), - Box::new(ArmorTemplate::FilthyRags), - Box::new(ArmorTemplate::FullPlateArmor), - Box::new(ArmorTemplate::HardLeatherArmor), - Box::new(ArmorTemplate::HardLeatherRingMail), - Box::new(ArmorTemplate::HardStuddedLeather), - Box::new(ArmorTemplate::LacqueredPlate), - Box::new(ArmorTemplate::LaminatedArmor), - Box::new(ArmorTemplate::LeatherBrigantineArmor), - Box::new(ArmorTemplate::LeatherScaleMail), - Box::new(ArmorTemplate::MetalBrigandineArmor), - Box::new(ArmorTemplate::MetalLamellarArmor), - Box::new(ArmorTemplate::MetalScaleMail), - Box::new(ArmorTemplate::MithrilChainMail), - Box::new(ArmorTemplate::MithrilPlateArmor), - Box::new(ArmorTemplate::PartialPlateArmor), - Box::new(ArmorTemplate::Robe), - Box::new(ArmorTemplate::RustyChainMail), - Box::new(ArmorTemplate::SoftLeatherArmor), - Box::new(ArmorTemplate::SoftLeatherRingMail), - Box::new(ArmorTemplate::SoftStuddedLeather), - Box::new(ArmorTemplate::StonePlateArmor), - Box::new(ArmorTemplate::WovenCordArmor), - Box::new(ArmorTemplate::WyrmhideArmor), - ] - } - - pub fn iter() -> impl Iterator> { - ArmorTemplate::vec().into_iter() - } -} - -impl item_template::ItemTemplate for ArmorTemplate { - - fn name(&self) -> &str { - match self { - ArmorTemplate::AugmentedChainMail => "Augmented Chain Mail^ [%P6,%P4]", - ArmorTemplate::BarChainMail => "Bar Chain Mail^ [%P6,%P4]", - ArmorTemplate::BronzePlateMail => "Bronze Plate Mail^ [%P6,%P4]", - ArmorTemplate::ChainMail => "Chain Mail^ [%P6,%P4]", - ArmorTemplate::CoolSetOfThreads => "Cool Set of Threads^ [%P6,%P4]", - ArmorTemplate::DemonhideArmor => "Demonhide Armor^ [%P6,%P4]", - ArmorTemplate::DoubleChainMail => "Double Chain Mail^ [%P6,%P4]", - ArmorTemplate::DuskShroud => "Dusk Shroud^ [%P6,%P4]", - ArmorTemplate::ElvenChainMail => "Elven Chain Mail^ [%P6,%P4]", - ArmorTemplate::FilthyNagaHideArmor => "Filthy Naga Hide Armor^ [%P6,%P4]", - ArmorTemplate::FilthyRags => "Filthy Rags^ [%P6,%P4]", - ArmorTemplate::FullPlateArmor => "Full Plate Armor^ [%P6,%P4]", - ArmorTemplate::HardLeatherArmor => "Hard Leather Armor^ [%P6,%P4]", - ArmorTemplate::HardLeatherRingMail => "Hard Leather Ring Mail^ [%P6,%P4]", - ArmorTemplate::HardStuddedLeather => "Hard Studded Leather^ [%P6,%P4]", - ArmorTemplate::LacqueredPlate => "Lacquered Plate^ [%P6,%P4]", - ArmorTemplate::LaminatedArmor => "Laminated Armor^ [%P6,%P4]", - ArmorTemplate::LeatherScaleMail => "Leather Scale Mail^ [%P6,%P4]", - ArmorTemplate::MetalBrigandineArmor => "Metal Brigandine Armor^ [%P6,%P4]", - ArmorTemplate::MetalLamellarArmor => "Metal Lamellar Armor^ [%P6,%P4]", - ArmorTemplate::MetalScaleMail => "Metal Scale Mail^ [%P6,%P4]", - ArmorTemplate::MithrilChainMail => "Mithril Chain Mail^ [%P6,%P4]", - ArmorTemplate::MithrilPlateArmor => "Mithril Plate Armor^ [%P6,%P4]", - ArmorTemplate::PartialPlateArmor => "Partial Plate Armor^ [%P6,%P4]", - ArmorTemplate::Robe => "Robe^ [%P6,%P4]", - ArmorTemplate::RustyChainMail => "Rusty Chain Mail^ [%P6,%P4]", - ArmorTemplate::SoftLeatherArmor => "Soft Leather Armor^ [%P6,%P4]", - ArmorTemplate::SoftLeatherRingMail => "Soft Leather Ring Mail^ [%P6,%P4]", - ArmorTemplate::SoftStuddedLeather => "Soft Studded Armor^ [%P6,%P4]", - ArmorTemplate::StonePlateArmor => "Stone Plate Armor^ [%P6,%P4]", - ArmorTemplate::WovenCordArmor => "Woven Cord Armor^ [%P6,%P4]", - ArmorTemplate::WyrmhideArmor => "Wyrmhide Armor^ [%P6,%P4]", - ArmorTemplate::LeatherBrigantineArmor => "Leather Brigantine Armor^ [%P6,%P4]", - } - } - - fn item_type(&self) -> model::ItemType { - match self { - ArmorTemplate::AugmentedChainMail => model::ItemType::HardArmor, - ArmorTemplate::BarChainMail => model::ItemType::HardArmor, - ArmorTemplate::BronzePlateMail => model::ItemType::HardArmor, - ArmorTemplate::ChainMail => model::ItemType::HardArmor, - ArmorTemplate::CoolSetOfThreads => model::ItemType::SoftArmor, - ArmorTemplate::DemonhideArmor => model::ItemType::SoftArmor, - ArmorTemplate::DoubleChainMail => model::ItemType::HardArmor, - ArmorTemplate::DuskShroud => model::ItemType::SoftArmor, - ArmorTemplate::ElvenChainMail => model::ItemType::SoftArmor, - ArmorTemplate::FilthyNagaHideArmor => model::ItemType::SoftArmor, - ArmorTemplate::FilthyRags => model::ItemType::SoftArmor, - ArmorTemplate::FullPlateArmor => model::ItemType::HardArmor, - ArmorTemplate::HardLeatherArmor => model::ItemType::SoftArmor, - ArmorTemplate::HardLeatherRingMail => model::ItemType::SoftArmor, - ArmorTemplate::HardStuddedLeather => model::ItemType::SoftArmor, - ArmorTemplate::LacqueredPlate => model::ItemType::HardArmor, - ArmorTemplate::LaminatedArmor => model::ItemType::HardArmor, - ArmorTemplate::LeatherScaleMail => model::ItemType::SoftArmor, - ArmorTemplate::MetalBrigandineArmor => model::ItemType::HardArmor, - ArmorTemplate::MetalLamellarArmor => model::ItemType::HardArmor, - ArmorTemplate::MetalScaleMail => model::ItemType::HardArmor, - ArmorTemplate::MithrilChainMail => model::ItemType::HardArmor, - ArmorTemplate::MithrilPlateArmor => model::ItemType::HardArmor, - ArmorTemplate::PartialPlateArmor => model::ItemType::HardArmor, - ArmorTemplate::Robe => model::ItemType::SoftArmor, - ArmorTemplate::RustyChainMail => model::ItemType::HardArmor, - ArmorTemplate::SoftLeatherArmor => model::ItemType::SoftArmor, - ArmorTemplate::SoftLeatherRingMail => model::ItemType::SoftArmor, - ArmorTemplate::SoftStuddedLeather => model::ItemType::SoftArmor, - ArmorTemplate::StonePlateArmor => model::ItemType::HardArmor, - ArmorTemplate::WovenCordArmor => model::ItemType::SoftArmor, - ArmorTemplate::WyrmhideArmor => model::ItemType::SoftArmor, - ArmorTemplate::LeatherBrigantineArmor => model::ItemType::SoftArmor, - } - } - - - fn flags1(&self) -> u64 { 0 } - fn flags2(&self) -> u64 { 0 } - fn p1(&self) -> i64 { 0 } - fn cost(&self) -> i64 { - match self { - ArmorTemplate::AugmentedChainMail => 675, - ArmorTemplate::BarChainMail => 720, - ArmorTemplate::BronzePlateMail => 700, - ArmorTemplate::ChainMail => 530, - ArmorTemplate::CoolSetOfThreads => 45, - ArmorTemplate::DemonhideArmor => 1000, - ArmorTemplate::DoubleChainMail => 630, - ArmorTemplate::DuskShroud => 600, - ArmorTemplate::ElvenChainMail => 900, - ArmorTemplate::FilthyNagaHideArmor => 45, - ArmorTemplate::FilthyRags => 0, - ArmorTemplate::FullPlateArmor => 1050, - ArmorTemplate::HardLeatherArmor => 55, - ArmorTemplate::HardLeatherRingMail => 230, - ArmorTemplate::HardStuddedLeather => 100, - ArmorTemplate::LacqueredPlate => 1200, - ArmorTemplate::LaminatedArmor => 825, - ArmorTemplate::LeatherScaleMail => 330, - ArmorTemplate::MetalBrigandineArmor => 775, - ArmorTemplate::MetalLamellarArmor => 950, - ArmorTemplate::MetalScaleMail => 430, - ArmorTemplate::MithrilChainMail => 1800, - ArmorTemplate::MithrilPlateArmor => 3600, - ArmorTemplate::PartialPlateArmor => 900, - ArmorTemplate::Robe => 4, - ArmorTemplate::RustyChainMail => 330, - ArmorTemplate::SoftLeatherArmor => 8, - ArmorTemplate::SoftLeatherRingMail => 160, - ArmorTemplate::SoftStuddedLeather => 35, - ArmorTemplate::StonePlateArmor => 45, - ArmorTemplate::WovenCordArmor => 45, - ArmorTemplate::WyrmhideArmor => 1200, - ArmorTemplate::LeatherBrigantineArmor => 300, - } - } - - - fn subtype(&self) -> i64 { - match self { - ArmorTemplate::AugmentedChainMail => 5, - ArmorTemplate::BarChainMail => 6, - ArmorTemplate::BronzePlateMail => 13, - ArmorTemplate::ChainMail => 2, - ArmorTemplate::CoolSetOfThreads => 11, - ArmorTemplate::DemonhideArmor => 15, - ArmorTemplate::DoubleChainMail => 4, - ArmorTemplate::DuskShroud => 14, - ArmorTemplate::ElvenChainMail => 13, - ArmorTemplate::FilthyNagaHideArmor => 12, - ArmorTemplate::FilthyRags => 99, - ArmorTemplate::FullPlateArmor => 11, - ArmorTemplate::HardLeatherArmor => 4, - ArmorTemplate::HardLeatherRingMail => 8, - ArmorTemplate::HardStuddedLeather => 5, - ArmorTemplate::LacqueredPlate => 12, - ArmorTemplate::LaminatedArmor => 8, - ArmorTemplate::LeatherScaleMail => 9, - ArmorTemplate::MetalBrigandineArmor => 7, - ArmorTemplate::MetalLamellarArmor => 10, - ArmorTemplate::MetalScaleMail => 1, - ArmorTemplate::MithrilChainMail => 15, - ArmorTemplate::MithrilPlateArmor => 16, - ArmorTemplate::PartialPlateArmor => 9, - ArmorTemplate::Robe => 1, - ArmorTemplate::RustyChainMail => 3, - ArmorTemplate::SoftLeatherArmor => 2, - ArmorTemplate::SoftLeatherRingMail => 7, - ArmorTemplate::SoftStuddedLeather => 3, - ArmorTemplate::StonePlateArmor => 14, - ArmorTemplate::WovenCordArmor => 6, - ArmorTemplate::WyrmhideArmor => 16, - ArmorTemplate::LeatherBrigantineArmor => 10, - } - } - - fn weight(&self) -> u16 { - match self { - ArmorTemplate::AugmentedChainMail => 270, - ArmorTemplate::BarChainMail => 280, - ArmorTemplate::BronzePlateMail => 380, - ArmorTemplate::ChainMail => 220, - ArmorTemplate::CoolSetOfThreads => 75, - ArmorTemplate::DemonhideArmor => 150, - ArmorTemplate::DoubleChainMail => 260, - ArmorTemplate::DuskShroud => 150, - ArmorTemplate::ElvenChainMail => 160, - ArmorTemplate::FilthyNagaHideArmor => 300, - ArmorTemplate::FilthyRags => 20, - ArmorTemplate::FullPlateArmor => 380, - ArmorTemplate::HardLeatherArmor => 100, - ArmorTemplate::HardLeatherRingMail => 150, - ArmorTemplate::HardStuddedLeather => 110, - ArmorTemplate::LacqueredPlate => 380, - ArmorTemplate::LaminatedArmor => 300, - ArmorTemplate::LeatherScaleMail => 140, - ArmorTemplate::MetalBrigandineArmor => 290, - ArmorTemplate::MetalLamellarArmor => 340, - ArmorTemplate::MetalScaleMail => 250, - ArmorTemplate::MithrilChainMail => 240, - ArmorTemplate::MithrilPlateArmor => 400, - ArmorTemplate::PartialPlateArmor => 260, - ArmorTemplate::Robe => 20, - ArmorTemplate::RustyChainMail => 0, - ArmorTemplate::SoftLeatherArmor => 80, - ArmorTemplate::SoftLeatherRingMail => 130, - ArmorTemplate::SoftStuddedLeather => 90, - ArmorTemplate::StonePlateArmor => 600, - ArmorTemplate::WovenCordArmor => 150, - ArmorTemplate::WyrmhideArmor => 150, - ArmorTemplate::LeatherBrigantineArmor => 190, - } - } - - fn number(&self) -> u16 { 1 } - - fn modifier_to_hit(&self) -> i16 { - match self { - ArmorTemplate::AugmentedChainMail => -2, - ArmorTemplate::BarChainMail => -2, - ArmorTemplate::BronzePlateMail => -4, - ArmorTemplate::ChainMail => -2, - ArmorTemplate::CoolSetOfThreads => -1, - ArmorTemplate::DemonhideArmor => -1, - ArmorTemplate::DoubleChainMail => -2, - ArmorTemplate::DuskShroud => -1, - ArmorTemplate::ElvenChainMail => -1, - ArmorTemplate::FilthyNagaHideArmor => -1, - ArmorTemplate::FilthyRags => 0, - ArmorTemplate::FullPlateArmor => -3, - ArmorTemplate::HardLeatherArmor => -1, - ArmorTemplate::HardLeatherRingMail => -2, - ArmorTemplate::HardStuddedLeather => -1, - ArmorTemplate::LacqueredPlate => -3, - ArmorTemplate::LaminatedArmor => -3, - ArmorTemplate::LeatherScaleMail => -1, - ArmorTemplate::MetalBrigandineArmor => -3, - ArmorTemplate::MetalLamellarArmor => -3, - ArmorTemplate::MetalScaleMail => -2, - ArmorTemplate::MithrilChainMail => -1, - ArmorTemplate::MithrilPlateArmor => -1, - ArmorTemplate::PartialPlateArmor => -3, - ArmorTemplate::Robe => 0, - ArmorTemplate::RustyChainMail => -5, - ArmorTemplate::SoftLeatherArmor => 0, - ArmorTemplate::SoftLeatherRingMail => -1, - ArmorTemplate::SoftStuddedLeather => 0, - ArmorTemplate::StonePlateArmor => -6, - ArmorTemplate::WovenCordArmor => -1, - ArmorTemplate::WyrmhideArmor => -1, - ArmorTemplate::LeatherBrigantineArmor => -1, - } - } - - fn modifier_to_damage(&self) -> i16 { 0 } - - fn base_ac(&self) -> i16 { - match self { - ArmorTemplate::AugmentedChainMail => 16, - ArmorTemplate::BarChainMail => 18, - ArmorTemplate::BronzePlateMail => 21, - ArmorTemplate::ChainMail => 14, - ArmorTemplate::CoolSetOfThreads => 3, - ArmorTemplate::DemonhideArmor => 20, - ArmorTemplate::DoubleChainMail => 15, - ArmorTemplate::DuskShroud => 14, - ArmorTemplate::ElvenChainMail => 17, - ArmorTemplate::FilthyNagaHideArmor => 9, - ArmorTemplate::FilthyRags => 0, - ArmorTemplate::FullPlateArmor => 25, - ArmorTemplate::HardLeatherArmor => 6, - ArmorTemplate::HardLeatherRingMail => 8, - ArmorTemplate::HardStuddedLeather => 7, - ArmorTemplate::LacqueredPlate => 28, - ArmorTemplate::LaminatedArmor => 20, - ArmorTemplate::LeatherScaleMail => 11, - ArmorTemplate::MetalBrigandineArmor => 19, - ArmorTemplate::MetalLamellarArmor => 23, - ArmorTemplate::MetalScaleMail => 13, - ArmorTemplate::MithrilChainMail => 24, - ArmorTemplate::MithrilPlateArmor => 32, - ArmorTemplate::PartialPlateArmor => 22, - ArmorTemplate::Robe => 2, - ArmorTemplate::RustyChainMail => 14, - ArmorTemplate::SoftLeatherArmor => 2, - ArmorTemplate::SoftLeatherRingMail => 6, - ArmorTemplate::SoftStuddedLeather => 5, - ArmorTemplate::StonePlateArmor => 10, - ArmorTemplate::WovenCordArmor => 6, - ArmorTemplate::WyrmhideArmor => 25, - ArmorTemplate::LeatherBrigantineArmor => 12, - } - } - - fn modifier_to_ac(&self) -> i16 { 0 } - fn damage(&self) -> &str { "1d1" } - - fn item_level(&self) -> u8 { - match self { - ArmorTemplate::AugmentedChainMail => 30, - ArmorTemplate::BarChainMail => 34, - ArmorTemplate::BronzePlateMail => 32, - ArmorTemplate::ChainMail => 26, - ArmorTemplate::CoolSetOfThreads => 255, - ArmorTemplate::DemonhideArmor => 255, - ArmorTemplate::DoubleChainMail => 28, - ArmorTemplate::DuskShroud => 30, - ArmorTemplate::ElvenChainMail => 255, - ArmorTemplate::FilthyNagaHideArmor => 255, - ArmorTemplate::FilthyRags => 0, - ArmorTemplate::FullPlateArmor => 48, - ArmorTemplate::HardLeatherArmor => 5, - ArmorTemplate::HardLeatherRingMail => 12, - ArmorTemplate::HardStuddedLeather => 7, - ArmorTemplate::LacqueredPlate => 40, - ArmorTemplate::LaminatedArmor => 38, - ArmorTemplate::LeatherBrigantineArmor => 20, - ArmorTemplate::LeatherScaleMail => 16, - ArmorTemplate::MetalBrigandineArmor => 36, - ArmorTemplate::MetalLamellarArmor => 44, - ArmorTemplate::MetalScaleMail => 24, - ArmorTemplate::MithrilChainMail => 255, - ArmorTemplate::MithrilPlateArmor => 255, - ArmorTemplate::PartialPlateArmor => 42, - ArmorTemplate::Robe => 1, - ArmorTemplate::RustyChainMail => 26, - ArmorTemplate::SoftLeatherArmor => 2, - ArmorTemplate::SoftLeatherRingMail => 10, - ArmorTemplate::SoftStuddedLeather => 3, - ArmorTemplate::StonePlateArmor => 255, - ArmorTemplate::WovenCordArmor => 7, - ArmorTemplate::WyrmhideArmor => 50, - } - } - - fn is_identified(&self) -> bool { false } -} diff --git a/src/item_template/armor_hard.rs b/src/item_template/armor_hard.rs new file mode 100644 index 00000000..50d3108a --- /dev/null +++ b/src/item_template/armor_hard.rs @@ -0,0 +1,215 @@ +use model; +use item_template; + +#[derive(Copy, Clone, Eq, PartialEq, Hash)] +pub enum HardArmorTemplate { + AugmentedChainMail, + BarChainMail, + BronzePlateMail, + ChainMail, + DoubleChainMail, + FullPlateArmor, + LacqueredPlate, + LaminatedArmor, + MetalBrigandineArmor, + MetalLamellarArmor, + MetalScaleMail, + MithrilChainMail, + MithrilPlateArmor, + PartialPlateArmor, + RustyChainMail, + StonePlateArmor, +} + + +impl HardArmorTemplate { + pub fn vec() -> Vec> { + vec![ + Box::new(HardArmorTemplate::AugmentedChainMail), + Box::new(HardArmorTemplate::BarChainMail), + Box::new(HardArmorTemplate::BronzePlateMail), + Box::new(HardArmorTemplate::ChainMail), + Box::new(HardArmorTemplate::DoubleChainMail), + Box::new(HardArmorTemplate::FullPlateArmor), + Box::new(HardArmorTemplate::LacqueredPlate), + Box::new(HardArmorTemplate::LaminatedArmor), + Box::new(HardArmorTemplate::MetalBrigandineArmor), + Box::new(HardArmorTemplate::MetalLamellarArmor), + Box::new(HardArmorTemplate::MetalScaleMail), + Box::new(HardArmorTemplate::MithrilChainMail), + Box::new(HardArmorTemplate::MithrilPlateArmor), + Box::new(HardArmorTemplate::PartialPlateArmor), + Box::new(HardArmorTemplate::RustyChainMail), + Box::new(HardArmorTemplate::StonePlateArmor), + ] + } + + pub fn iter() -> impl Iterator> { + HardArmorTemplate::vec().into_iter() + } + + pub fn from(subval: i64) -> Box { + match subval { + 5 => Box::new(HardArmorTemplate::AugmentedChainMail), + 6 => Box::new(HardArmorTemplate::BarChainMail), + 13 => Box::new(HardArmorTemplate::BronzePlateMail), + 2 => Box::new(HardArmorTemplate::ChainMail), + 4 => Box::new(HardArmorTemplate::DoubleChainMail), + 11 => Box::new(HardArmorTemplate::FullPlateArmor), + 12 => Box::new(HardArmorTemplate::LacqueredPlate), + 8 => Box::new(HardArmorTemplate::LaminatedArmor), + 7 => Box::new(HardArmorTemplate::MetalBrigandineArmor), + 10 => Box::new(HardArmorTemplate::MetalLamellarArmor), + 1 => Box::new(HardArmorTemplate::MetalScaleMail), + 15 => Box::new(HardArmorTemplate::MithrilChainMail), + 16 => Box::new(HardArmorTemplate::MithrilPlateArmor), + 9 => Box::new(HardArmorTemplate::PartialPlateArmor), + 3 => Box::new(HardArmorTemplate::RustyChainMail), + 14 => Box::new(HardArmorTemplate::StonePlateArmor), + _ => panic!("subval {} out of bounds", subval), + } + } +} + +impl item_template::ItemTemplate for HardArmorTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::HardArmor } + fn flags1(&self) -> u64 { 0 } + fn flags2(&self) -> u64 { 0 } + fn p1(&self) -> i64 { 0 } + fn cost(&self) -> i64 { + match self { + HardArmorTemplate::AugmentedChainMail => 675, + HardArmorTemplate::BarChainMail => 720, + HardArmorTemplate::BronzePlateMail => 700, + HardArmorTemplate::ChainMail => 530, + HardArmorTemplate::DoubleChainMail => 630, + HardArmorTemplate::FullPlateArmor => 1050, + HardArmorTemplate::LacqueredPlate => 1200, + HardArmorTemplate::LaminatedArmor => 825, + HardArmorTemplate::MetalBrigandineArmor => 775, + HardArmorTemplate::MetalLamellarArmor => 950, + HardArmorTemplate::MetalScaleMail => 430, + HardArmorTemplate::MithrilChainMail => 1800, + HardArmorTemplate::MithrilPlateArmor => 3600, + HardArmorTemplate::PartialPlateArmor => 900, + HardArmorTemplate::RustyChainMail => 330, + HardArmorTemplate::StonePlateArmor => 45, + } + } + + + fn subtype(&self) -> i64 { + match self { + HardArmorTemplate::AugmentedChainMail => 5, + HardArmorTemplate::BarChainMail => 6, + HardArmorTemplate::BronzePlateMail => 13, + HardArmorTemplate::ChainMail => 2, + HardArmorTemplate::DoubleChainMail => 4, + HardArmorTemplate::FullPlateArmor => 11, + HardArmorTemplate::LacqueredPlate => 12, + HardArmorTemplate::LaminatedArmor => 8, + HardArmorTemplate::MetalBrigandineArmor => 7, + HardArmorTemplate::MetalLamellarArmor => 10, + HardArmorTemplate::MetalScaleMail => 1, + HardArmorTemplate::MithrilChainMail => 15, + HardArmorTemplate::MithrilPlateArmor => 16, + HardArmorTemplate::PartialPlateArmor => 9, + HardArmorTemplate::RustyChainMail => 3, + HardArmorTemplate::StonePlateArmor => 14, + } + } + + fn weight(&self) -> u16 { + match self { + HardArmorTemplate::AugmentedChainMail => 270, + HardArmorTemplate::BarChainMail => 280, + HardArmorTemplate::BronzePlateMail => 380, + HardArmorTemplate::ChainMail => 220, + HardArmorTemplate::DoubleChainMail => 260, + HardArmorTemplate::FullPlateArmor => 380, + HardArmorTemplate::LacqueredPlate => 380, + HardArmorTemplate::LaminatedArmor => 300, + HardArmorTemplate::MetalBrigandineArmor => 290, + HardArmorTemplate::MetalLamellarArmor => 340, + HardArmorTemplate::MetalScaleMail => 250, + HardArmorTemplate::MithrilChainMail => 240, + HardArmorTemplate::MithrilPlateArmor => 400, + HardArmorTemplate::PartialPlateArmor => 260, + HardArmorTemplate::RustyChainMail => 0, + HardArmorTemplate::StonePlateArmor => 600, + } + } + + fn number(&self) -> u16 { 1 } + + fn modifier_to_hit(&self) -> i16 { + match self { + HardArmorTemplate::AugmentedChainMail => -2, + HardArmorTemplate::BarChainMail => -2, + HardArmorTemplate::BronzePlateMail => -4, + HardArmorTemplate::ChainMail => -2, + HardArmorTemplate::DoubleChainMail => -2, + HardArmorTemplate::FullPlateArmor => -3, + HardArmorTemplate::LacqueredPlate => -3, + HardArmorTemplate::LaminatedArmor => -3, + HardArmorTemplate::MetalBrigandineArmor => -3, + HardArmorTemplate::MetalLamellarArmor => -3, + HardArmorTemplate::MetalScaleMail => -2, + HardArmorTemplate::MithrilChainMail => -1, + HardArmorTemplate::MithrilPlateArmor => -1, + HardArmorTemplate::PartialPlateArmor => -3, + HardArmorTemplate::RustyChainMail => -5, + HardArmorTemplate::StonePlateArmor => -6, + } + } + + fn modifier_to_damage(&self) -> i16 { 0 } + + fn base_ac(&self) -> i16 { + match self { + HardArmorTemplate::AugmentedChainMail => 16, + HardArmorTemplate::BarChainMail => 18, + HardArmorTemplate::BronzePlateMail => 21, + HardArmorTemplate::ChainMail => 14, + HardArmorTemplate::DoubleChainMail => 15, + HardArmorTemplate::FullPlateArmor => 25, + HardArmorTemplate::LacqueredPlate => 28, + HardArmorTemplate::LaminatedArmor => 20, + HardArmorTemplate::MetalBrigandineArmor => 19, + HardArmorTemplate::MetalLamellarArmor => 23, + HardArmorTemplate::MetalScaleMail => 13, + HardArmorTemplate::MithrilChainMail => 24, + HardArmorTemplate::MithrilPlateArmor => 32, + HardArmorTemplate::PartialPlateArmor => 22, + HardArmorTemplate::RustyChainMail => 14, + HardArmorTemplate::StonePlateArmor => 10, + } + } + + fn modifier_to_ac(&self) -> i16 { 0 } + fn damage(&self) -> &str { "1d1" } + + fn item_level(&self) -> u8 { + match self { + HardArmorTemplate::AugmentedChainMail => 30, + HardArmorTemplate::BarChainMail => 34, + HardArmorTemplate::BronzePlateMail => 32, + HardArmorTemplate::ChainMail => 26, + HardArmorTemplate::DoubleChainMail => 28, + HardArmorTemplate::FullPlateArmor => 48, + HardArmorTemplate::LacqueredPlate => 40, + HardArmorTemplate::LaminatedArmor => 38, + HardArmorTemplate::MetalBrigandineArmor => 36, + HardArmorTemplate::MetalLamellarArmor => 44, + HardArmorTemplate::MetalScaleMail => 24, + HardArmorTemplate::MithrilChainMail => 255, + HardArmorTemplate::MithrilPlateArmor => 255, + HardArmorTemplate::PartialPlateArmor => 42, + HardArmorTemplate::RustyChainMail => 26, + HardArmorTemplate::StonePlateArmor => 255, + } + } + + fn is_identified(&self) -> bool { false } +} + diff --git a/src/item_template/armor_soft.rs b/src/item_template/armor_soft.rs new file mode 100644 index 00000000..0aa69e09 --- /dev/null +++ b/src/item_template/armor_soft.rs @@ -0,0 +1,225 @@ +use model; +use item_template; + +#[derive(Copy, Clone, Eq, PartialEq, Hash)] +pub enum SoftArmorTemplate { + CoolSetOfThreads, + DemonhideArmor, + DuskShroud, + ElvenChainMail, + FilthyNagaHideArmor, + FilthyRags, + HardLeatherArmor, + HardLeatherRingMail, + HardStuddedLeather, + LeatherScaleMail, + Robe, + SoftLeatherArmor, + SoftLeatherRingMail, + SoftStuddedLeather, + WovenCordArmor, + WyrmhideArmor, + LeatherBrigantineArmor, +} + + +impl SoftArmorTemplate { + pub fn vec() -> Vec> { + vec![ + Box::new(SoftArmorTemplate::CoolSetOfThreads), + Box::new(SoftArmorTemplate::DemonhideArmor), + Box::new(SoftArmorTemplate::DuskShroud), + Box::new(SoftArmorTemplate::ElvenChainMail), + Box::new(SoftArmorTemplate::FilthyNagaHideArmor), + Box::new(SoftArmorTemplate::FilthyRags), + Box::new(SoftArmorTemplate::HardLeatherArmor), + Box::new(SoftArmorTemplate::HardLeatherRingMail), + Box::new(SoftArmorTemplate::HardStuddedLeather), + Box::new(SoftArmorTemplate::LeatherScaleMail), + Box::new(SoftArmorTemplate::Robe), + Box::new(SoftArmorTemplate::SoftLeatherArmor), + Box::new(SoftArmorTemplate::SoftLeatherRingMail), + Box::new(SoftArmorTemplate::SoftStuddedLeather), + Box::new(SoftArmorTemplate::WovenCordArmor), + Box::new(SoftArmorTemplate::WyrmhideArmor), + Box::new(SoftArmorTemplate::LeatherBrigantineArmor), + ] + } + + pub fn iter() -> impl Iterator> { + SoftArmorTemplate::vec().into_iter() + } + + pub fn from(subval: i64) -> Box { + match subval { + 11 => Box::new(SoftArmorTemplate::CoolSetOfThreads), + 15 => Box::new(SoftArmorTemplate::DemonhideArmor), + 14 => Box::new(SoftArmorTemplate::DuskShroud), + 13 => Box::new(SoftArmorTemplate::ElvenChainMail), + 12 => Box::new(SoftArmorTemplate::FilthyNagaHideArmor), + 99 => Box::new(SoftArmorTemplate::FilthyRags), + 4 => Box::new(SoftArmorTemplate::HardLeatherArmor), + 8 => Box::new(SoftArmorTemplate::HardLeatherRingMail), + 5 => Box::new(SoftArmorTemplate::HardStuddedLeather), + 9 => Box::new(SoftArmorTemplate::LeatherScaleMail), + 1 => Box::new(SoftArmorTemplate::Robe), + 2 => Box::new(SoftArmorTemplate::SoftLeatherArmor), + 7 => Box::new(SoftArmorTemplate::SoftLeatherRingMail), + 3 => Box::new(SoftArmorTemplate::SoftStuddedLeather), + 6 => Box::new(SoftArmorTemplate::WovenCordArmor), + 16 => Box::new(SoftArmorTemplate::WyrmhideArmor), + 10 => Box::new(SoftArmorTemplate::LeatherBrigantineArmor), + _ => panic!("subval {} out of bounds", subval), + } + } +} + +impl item_template::ItemTemplate for SoftArmorTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::SoftArmor } + fn flags1(&self) -> u64 { 0 } + fn flags2(&self) -> u64 { 0 } + fn p1(&self) -> i64 { 0 } + fn cost(&self) -> i64 { + match self { + SoftArmorTemplate::CoolSetOfThreads => 45, + SoftArmorTemplate::DemonhideArmor => 1000, + SoftArmorTemplate::DuskShroud => 600, + SoftArmorTemplate::ElvenChainMail => 900, + SoftArmorTemplate::FilthyNagaHideArmor => 45, + SoftArmorTemplate::FilthyRags => 0, + SoftArmorTemplate::HardLeatherArmor => 55, + SoftArmorTemplate::HardLeatherRingMail => 230, + SoftArmorTemplate::HardStuddedLeather => 100, + SoftArmorTemplate::LeatherScaleMail => 330, + SoftArmorTemplate::Robe => 4, + SoftArmorTemplate::SoftLeatherArmor => 8, + SoftArmorTemplate::SoftLeatherRingMail => 160, + SoftArmorTemplate::SoftStuddedLeather => 35, + SoftArmorTemplate::WovenCordArmor => 45, + SoftArmorTemplate::WyrmhideArmor => 1200, + SoftArmorTemplate::LeatherBrigantineArmor => 300, + } + } + + + fn subtype(&self) -> i64 { + match self { + SoftArmorTemplate::CoolSetOfThreads => 11, + SoftArmorTemplate::DemonhideArmor => 15, + SoftArmorTemplate::DuskShroud => 14, + SoftArmorTemplate::ElvenChainMail => 13, + SoftArmorTemplate::FilthyNagaHideArmor => 12, + SoftArmorTemplate::FilthyRags => 99, + SoftArmorTemplate::HardLeatherArmor => 4, + SoftArmorTemplate::HardLeatherRingMail => 8, + SoftArmorTemplate::HardStuddedLeather => 5, + SoftArmorTemplate::LeatherScaleMail => 9, + SoftArmorTemplate::Robe => 1, + SoftArmorTemplate::SoftLeatherArmor => 2, + SoftArmorTemplate::SoftLeatherRingMail => 7, + SoftArmorTemplate::SoftStuddedLeather => 3, + SoftArmorTemplate::WovenCordArmor => 6, + SoftArmorTemplate::WyrmhideArmor => 16, + SoftArmorTemplate::LeatherBrigantineArmor => 10, + } + } + + fn weight(&self) -> u16 { + match self { + SoftArmorTemplate::CoolSetOfThreads => 75, + SoftArmorTemplate::DemonhideArmor => 150, + SoftArmorTemplate::DuskShroud => 150, + SoftArmorTemplate::ElvenChainMail => 160, + SoftArmorTemplate::FilthyNagaHideArmor => 300, + SoftArmorTemplate::FilthyRags => 20, + SoftArmorTemplate::HardLeatherArmor => 100, + SoftArmorTemplate::HardLeatherRingMail => 150, + SoftArmorTemplate::HardStuddedLeather => 110, + SoftArmorTemplate::LeatherScaleMail => 140, + SoftArmorTemplate::Robe => 20, + SoftArmorTemplate::SoftLeatherArmor => 80, + SoftArmorTemplate::SoftLeatherRingMail => 130, + SoftArmorTemplate::SoftStuddedLeather => 90, + SoftArmorTemplate::WovenCordArmor => 150, + SoftArmorTemplate::WyrmhideArmor => 150, + SoftArmorTemplate::LeatherBrigantineArmor => 190, + } + } + + fn number(&self) -> u16 { 1 } + + fn modifier_to_hit(&self) -> i16 { + match self { + SoftArmorTemplate::CoolSetOfThreads => -1, + SoftArmorTemplate::DemonhideArmor => -1, + SoftArmorTemplate::DuskShroud => -1, + SoftArmorTemplate::ElvenChainMail => -1, + SoftArmorTemplate::FilthyNagaHideArmor => -1, + SoftArmorTemplate::FilthyRags => 0, + SoftArmorTemplate::HardLeatherArmor => -1, + SoftArmorTemplate::HardLeatherRingMail => -2, + SoftArmorTemplate::HardStuddedLeather => -1, + SoftArmorTemplate::LeatherScaleMail => -1, + SoftArmorTemplate::Robe => 0, + SoftArmorTemplate::SoftLeatherArmor => 0, + SoftArmorTemplate::SoftLeatherRingMail => -1, + SoftArmorTemplate::SoftStuddedLeather => 0, + SoftArmorTemplate::WovenCordArmor => -1, + SoftArmorTemplate::WyrmhideArmor => -1, + SoftArmorTemplate::LeatherBrigantineArmor => -1, + } + } + + fn modifier_to_damage(&self) -> i16 { 0 } + + fn base_ac(&self) -> i16 { + match self { + SoftArmorTemplate::CoolSetOfThreads => 3, + SoftArmorTemplate::DemonhideArmor => 20, + SoftArmorTemplate::DuskShroud => 14, + SoftArmorTemplate::ElvenChainMail => 17, + SoftArmorTemplate::FilthyNagaHideArmor => 9, + SoftArmorTemplate::FilthyRags => 0, + SoftArmorTemplate::HardLeatherArmor => 6, + SoftArmorTemplate::HardLeatherRingMail => 8, + SoftArmorTemplate::HardStuddedLeather => 7, + SoftArmorTemplate::LeatherScaleMail => 11, + SoftArmorTemplate::Robe => 2, + SoftArmorTemplate::SoftLeatherArmor => 2, + SoftArmorTemplate::SoftLeatherRingMail => 6, + SoftArmorTemplate::SoftStuddedLeather => 5, + SoftArmorTemplate::WovenCordArmor => 6, + SoftArmorTemplate::WyrmhideArmor => 25, + SoftArmorTemplate::LeatherBrigantineArmor => 12, + } + } + + fn modifier_to_ac(&self) -> i16 { 0 } + fn damage(&self) -> &str { "1d1" } + + fn item_level(&self) -> u8 { + match self { + SoftArmorTemplate::CoolSetOfThreads => 255, + SoftArmorTemplate::DemonhideArmor => 255, + SoftArmorTemplate::DuskShroud => 30, + SoftArmorTemplate::ElvenChainMail => 255, + SoftArmorTemplate::FilthyNagaHideArmor => 255, + SoftArmorTemplate::FilthyRags => 0, + SoftArmorTemplate::HardLeatherArmor => 5, + SoftArmorTemplate::HardLeatherRingMail => 12, + SoftArmorTemplate::HardStuddedLeather => 7, + SoftArmorTemplate::LeatherBrigantineArmor => 20, + SoftArmorTemplate::LeatherScaleMail => 16, + SoftArmorTemplate::Robe => 1, + SoftArmorTemplate::SoftLeatherArmor => 2, + SoftArmorTemplate::SoftLeatherRingMail => 10, + SoftArmorTemplate::SoftStuddedLeather => 3, + SoftArmorTemplate::WovenCordArmor => 7, + SoftArmorTemplate::WyrmhideArmor => 50, + } + } + + fn is_identified(&self) -> bool { false } +} + + diff --git a/src/item_template/axe.rs b/src/item_template/axe.rs index 9ede7048..6a767941 100644 --- a/src/item_template/axe.rs +++ b/src/item_template/axe.rs @@ -32,24 +32,25 @@ impl AxeTemplate { pub fn iter() -> impl Iterator> { AxeTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for AxeTemplate { - fn name(&self) -> &str { - match self { - AxeTemplate::Balestarius => "Balestarius (%P0)^ (%P2,%P3)", - AxeTemplate::BattleAxe => "Battle Axe (%P0)^ (%P2,%P3)", - AxeTemplate::BroadAxe => "Broad Axe (%P0)^ (%P2,%P3)", - AxeTemplate::HandAxe => "Hand Axe (%P0)^ (%P2,%P3)", - AxeTemplate::WarAxe => "War Axe (%P0)^ (%P2,%P3)", - AxeTemplate::LargeAxe => "Large Axe (%P0)^ (%P2,%P3)", - AxeTemplate::BeardedAxe => "Bearded Axe (%P0)^ (%P2,%P3)", - AxeTemplate::SilverEdgedAxe => "Silved Edged Axe (%P0)^ (%P2,%P3)", - AxeTemplate::ChampionAxe => "Champion Axe (%P0)^ (%P2,%P3)", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(AxeTemplate::Balestarius), + 3 => Box::new(AxeTemplate::BattleAxe), + 4 => Box::new(AxeTemplate::BroadAxe), + 5 => Box::new(AxeTemplate::HandAxe), + 6 => Box::new(AxeTemplate::WarAxe), + 7 => Box::new(AxeTemplate::LargeAxe), + 8 => Box::new(AxeTemplate::BeardedAxe), + 9 => Box::new(AxeTemplate::SilverEdgedAxe), + 10 => Box::new(AxeTemplate::ChampionAxe), + _ => panic!("subval {} out of bounds", subval), } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::HaftedWeapon } +impl item_template::ItemTemplate for AxeTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Axe } fn flags1(&self) -> u64 { 0x10000000 } fn flags2(&self) -> u64 { 0 } fn p1(&self) -> i64 { 0 } diff --git a/src/item_template/bag.rs b/src/item_template/bag.rs index 9b155a87..3c17417f 100644 --- a/src/item_template/bag.rs +++ b/src/item_template/bag.rs @@ -24,19 +24,20 @@ impl BagTemplate { pub fn iter() -> impl Iterator> { BagTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for BagTemplate { - fn name(&self) -> &str { - match self { - BagTemplate::BagOfHolding250 => "& Bag| of Holding (250)", - BagTemplate::BagOfHolding500 => "& Bag| of Holding (500)", - BagTemplate::BagOfHolding1000 => "& Bag| of Holding (1000)", - BagTemplate::BagOfHolding1500 => "& Bag| of Holding (1500)", - BagTemplate::BagOfDevouring => "& Bag| of Devouring", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(BagTemplate::BagOfHolding250), + 2 => Box::new(BagTemplate::BagOfHolding500), + 3 => Box::new(BagTemplate::BagOfHolding1000), + 4 => Box::new(BagTemplate::BagOfHolding1500), + 5 => Box::new(BagTemplate::BagOfDevouring), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for BagTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Bag } fn flags1(&self) -> u64 { @@ -76,8 +77,8 @@ impl item_template::ItemTemplate for BagTemplate { BagTemplate::BagOfHolding250 => 1, BagTemplate::BagOfHolding500 => 2, BagTemplate::BagOfHolding1000 => 3, - BagTemplate::BagOfHolding1500 => 3, - BagTemplate::BagOfDevouring => 4, + BagTemplate::BagOfHolding1500 => 4, + BagTemplate::BagOfDevouring => 5, } } diff --git a/src/item_template/belt.rs b/src/item_template/belt.rs index 09e077b8..3184297a 100644 --- a/src/item_template/belt.rs +++ b/src/item_template/belt.rs @@ -31,22 +31,23 @@ impl BeltTemplate { pub fn iter() -> impl Iterator> { BeltTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for BeltTemplate { - fn name(&self) -> &str { - match self { - BeltTemplate::Sash => "Sash^ [%P6,%P4]", - BeltTemplate::LightBelt => "Light Belt^ [%P6,%P4]", - BeltTemplate::Belt => "Belt^ [%P6,%P4]", - BeltTemplate::HeavyBelt => "Heavy Belt^ [%P6,%P4]", - BeltTemplate::LightPlatedBelt => "Light Plated Belt^ [%P6,%P4]", - BeltTemplate::SharkskinBelt => "Sharkskin Belt^ [%P6,%P4]", - BeltTemplate::DemonhideBelt => "Demonhide Belt^ [%P6,%P4]", - BeltTemplate::WyrmhideBelt => "Wyrmhide Belt^ [%P6,%P4]", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(BeltTemplate::Sash), + 2 => Box::new(BeltTemplate::LightBelt), + 3 => Box::new(BeltTemplate::Belt), + 4 => Box::new(BeltTemplate::HeavyBelt), + 5 => Box::new(BeltTemplate::LightPlatedBelt), + 6 => Box::new(BeltTemplate::SharkskinBelt), + 7 => Box::new(BeltTemplate::DemonhideBelt), + 8 => Box::new(BeltTemplate::WyrmhideBelt), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for BeltTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Belt } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/boots.rs b/src/item_template/boots.rs index fe06ad4d..4940eb30 100644 --- a/src/item_template/boots.rs +++ b/src/item_template/boots.rs @@ -29,26 +29,28 @@ impl BootsTemplate { Box::new(BootsTemplate::WyrmhideBoot), ] } + pub fn iter() -> impl Iterator> { BootsTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for BootsTemplate { - fn name(&self) -> &str { - match self { - BootsTemplate::SoftLeatherShoes => "Soft Leather Shoes^ [%P6,%P4]", - BootsTemplate::SoftLeatherBoots => "Soft Leather Boots^ [%P6,%P4]", - BootsTemplate::HardLeatherBoots => "Hard Leather Boots^ [%P6,%P4]", - BootsTemplate::Sandals => "Sandals^ [%P6,%P4]", - BootsTemplate::ChainBoots => "Chain Boots^ [%P6,%P4]", - BootsTemplate::LightPlatedBoots => "Light Plated Boots^ [%P6,%P4]", - BootsTemplate::SharkskinBoots => "Sharkskin Boots^ [%P6,%P4]", - BootsTemplate::DemonhideBoots => "Demonhide Boots^ [%P6,%P4]", - BootsTemplate::WyrmhideBoot => "Wyrmhide Boots^ [%P6,%P4]", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(BootsTemplate::SoftLeatherShoes), + 2 => Box::new(BootsTemplate::SoftLeatherBoots), + 3 => Box::new(BootsTemplate::HardLeatherBoots), + 4 => Box::new(BootsTemplate::Sandals), + 5 => Box::new(BootsTemplate::ChainBoots), + 6 => Box::new(BootsTemplate::LightPlatedBoots), + 7 => Box::new(BootsTemplate::SharkskinBoots), + 8 => Box::new(BootsTemplate::DemonhideBoots), + 9 => Box::new(BootsTemplate::WyrmhideBoot), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for BootsTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Boots } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/bow.rs b/src/item_template/bow.rs index 319a4329..b53efbb6 100644 --- a/src/item_template/bow.rs +++ b/src/item_template/bow.rs @@ -29,22 +29,23 @@ impl BowTemplate { pub fn iter() -> impl Iterator> { BowTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for BowTemplate { - fn name(&self) -> &str { - match self { - BowTemplate::Shortbow => "Shortbow (%P0)^ (%P2,%P3)", - BowTemplate::HuntersBow => "Hunters Bow (%P0)^ (%P2,%P3)", - BowTemplate::CompositeBow => "Composite Bow (%P0)^ (%P2,%P3)", - BowTemplate::WarBow => "War Bow (%P0)^ (%P2,%P3)", - BowTemplate::DoubleBow => "Double Bow (%P0)^ (%P2,%P3)", - BowTemplate::SiegeBow => "Siege Bow (%P0)^ (%P2,%P3)", - BowTemplate::WardedBow => "Warded Bow (%P0)^ (%P2,%P3)", - } + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(BowTemplate::Shortbow), + 2 => Box::new(BowTemplate::HuntersBow), + 3 => Box::new(BowTemplate::CompositeBow), + 4 => Box::new(BowTemplate::WarBow), + 5 => Box::new(BowTemplate::DoubleBow), + 6 => Box::new(BowTemplate::SiegeBow), + 7 => Box::new(BowTemplate::WardedBow), + _ => panic!("subval {} out of bounds", subval), + } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::RangedWeapon } +impl item_template::ItemTemplate for BowTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Bow } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/bracers.rs b/src/item_template/bracers.rs index b00fb44a..4ecc8735 100644 --- a/src/item_template/bracers.rs +++ b/src/item_template/bracers.rs @@ -51,32 +51,33 @@ impl BracersTemplate { pub fn iter() -> impl Iterator> { BracersTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for BracersTemplate { - fn name(&self) -> &str { - match self { - BracersTemplate::BracersOfProtection => "Bracers^ of Protection [%P6,%P4]", - BracersTemplate::BracersOfDefense => "Bracers^ of Defense [%P6,%P4]", - BracersTemplate::BracersOfShielding => "Bracers^ of Shielding [%P6,%P4]", - BracersTemplate::MithrilBracers => "Mithril Bracers^ [%P6,%P4]", - BracersTemplate::AdamantiteBracers => "Adamantite Bracers^ [%P6,%P4]", - BracersTemplate::BracersOfWeaponAttraction => "Bracers^ of Weapon Attraction [%P6,%P4]", - BracersTemplate::SilverBraceletOfWarding => "Silver Bracelet^ of Warding [%P6,%P4] (R)", - BracersTemplate::SilverBracelet => "Silver Bracelet^ [%P6,%P4]", - BracersTemplate::GoldBracelet => "Gold Bracelet^ [%P6,%P4]", - BracersTemplate::PlatinumBracelet => "Platinum Bracelet^ [%P6,%P4]", - BracersTemplate::LeatherBracers => "Leather Bracers^ [%P6,%P4]", - BracersTemplate::StuddedLeatherBracers => "Studded Leather Bracers^ [%P6,%P4]", - BracersTemplate::LightPlatedBracers => "Light Plated Bracers^ [%P6,%P4]", - BracersTemplate::SharkskinBracers => "Sharkskin Bracers^ [%P6,%P4]", - BracersTemplate::DemonhideBracers => "Demonhide Bracers^ [%P6,%P4]", - BracersTemplate::WyrmhideBracers => "Wyrmhide Bracers^ [%P6,%P4]", - BracersTemplate::ChainmailBracers => "Chainmail Bracers^ [%P6,%P4]", - BracersTemplate::LamellarBracers => "Lamellar Bracers^ [%P6,%P4]", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(BracersTemplate::BracersOfProtection), + 2 => Box::new(BracersTemplate::BracersOfDefense), + 3 => Box::new(BracersTemplate::BracersOfShielding), + 4 => Box::new(BracersTemplate::MithrilBracers), + 5 => Box::new(BracersTemplate::AdamantiteBracers), + 6 => Box::new(BracersTemplate::BracersOfWeaponAttraction), + 31 => Box::new(BracersTemplate::SilverBraceletOfWarding), + 30 => Box::new(BracersTemplate::SilverBracelet), + 40 => Box::new(BracersTemplate::GoldBracelet), + 50 => Box::new(BracersTemplate::PlatinumBracelet), + 7 => Box::new(BracersTemplate::LeatherBracers), + 8 => Box::new(BracersTemplate::StuddedLeatherBracers), + 9 => Box::new(BracersTemplate::LightPlatedBracers), + 10 => Box::new(BracersTemplate::SharkskinBracers), + 11 => Box::new(BracersTemplate::DemonhideBracers), + 12 => Box::new(BracersTemplate::WyrmhideBracers), + 13 => Box::new(BracersTemplate::ChainmailBracers), + 14 => Box::new(BracersTemplate::LamellarBracers), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for BracersTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Bracers } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/chest.rs b/src/item_template/chest.rs index 10f4c001..6bedd63a 100644 --- a/src/item_template/chest.rs +++ b/src/item_template/chest.rs @@ -26,20 +26,21 @@ impl ChestTemplate { pub fn iter() -> impl Iterator> { ChestTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for ChestTemplate { - fn name(&self) -> &str { - match self { - ChestTemplate::SmallWoodenChest => "& Small wooden chest", - ChestTemplate::LargeWoodenChest => "& Large wooden chest", - ChestTemplate::SmallIronChest => "& Small iron chest", - ChestTemplate::LargeIronChest => "& Large iron chest", - ChestTemplate::SmallSteelChest => "& Small steel chest", - ChestTemplate::LargeSteelChest => "& Large steel chest", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(ChestTemplate::SmallWoodenChest), + 4 => Box::new(ChestTemplate::LargeWoodenChest), + 7 => Box::new(ChestTemplate::SmallIronChest), + 10 => Box::new(ChestTemplate::LargeIronChest), + 13 => Box::new(ChestTemplate::SmallSteelChest), + 16 => Box::new(ChestTemplate::LargeSteelChest), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for ChestTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Chest } fn flags1(&self) -> u64 { 0 } diff --git a/src/item_template/chime.rs b/src/item_template/chime.rs index 329bf130..c7df1b08 100644 --- a/src/item_template/chime.rs +++ b/src/item_template/chime.rs @@ -46,30 +46,31 @@ impl ChimeTemplate { pub fn iter() -> impl Iterator> { ChimeTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for ChimeTemplate { - fn name(&self) -> &str { - match self { - ChimeTemplate::ChimeOfLight => "& Chime| of Light^ (%P1 charges)", - ChimeTemplate::ChimeOfDetectDoorsStairs => "& Chime| of Detect Doors/Stairs^ (%P1 charges)", - ChimeTemplate::ChimeOfDetectTraps => "& Chime| of Detect Traps^ (%P1 charges)", - ChimeTemplate::ChimeOfTeleportation => "& Chime| of Teleportation^ (%P1 charges)", - ChimeTemplate::ChimeOfThunderblast => "& Chime| of Thunderblasts^ (%P1 charges)", - ChimeTemplate::ChimeOfSummonMonster => "& Chime| of Summon Monster^ (%P1 charges)", - ChimeTemplate::ChimeOfDisarming => "& Chime| of Disarming^ (%P1 charges)", - ChimeTemplate::ChimeOfAggravation => "& Chime| of Aggravation^ (%P1 charges)", - ChimeTemplate::ChimeOfSlowMonster => "& Chime| of Slow Monster^ (%P1 charges)", - ChimeTemplate::ChimeOfSootheMonster => "& Chime| of Soothe Monster^ (%P1 charges)", - ChimeTemplate::ChimeOfCureLightWound => "& Chime| of Cure Light Wound^ (%P1 charges)", - ChimeTemplate::ChimeOfChanging => "& Chime| of Changing^ (%P1 charges)", - ChimeTemplate::ChimeOfRemoveCurse => "& Chime| of Remove Curse^ (%P1 charges)", - ChimeTemplate::ChimeOfCuring => "& Chime| of Curing^ (%P1 charges)", - ChimeTemplate::ChimeOfDispelEvil => "& Chime| of Dispel Evil^ (%P1 charges)", - ChimeTemplate::ChimeOfDarkness => "& Chime| of Darkness^ (%P1 charges)", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(ChimeTemplate::ChimeOfLight), + 2 => Box::new(ChimeTemplate::ChimeOfDetectDoorsStairs), + 3 => Box::new(ChimeTemplate::ChimeOfDetectTraps), + 4 => Box::new(ChimeTemplate::ChimeOfTeleportation), + 5 => Box::new(ChimeTemplate::ChimeOfThunderblast), + 6 => Box::new(ChimeTemplate::ChimeOfSummonMonster), + 7 => Box::new(ChimeTemplate::ChimeOfDisarming), + 8 => Box::new(ChimeTemplate::ChimeOfAggravation), + 9 => Box::new(ChimeTemplate::ChimeOfSlowMonster), + 10 => Box::new(ChimeTemplate::ChimeOfSootheMonster), + 11 => Box::new(ChimeTemplate::ChimeOfCureLightWound), + 12 => Box::new(ChimeTemplate::ChimeOfChanging), + 13 => Box::new(ChimeTemplate::ChimeOfRemoveCurse), + 14 => Box::new(ChimeTemplate::ChimeOfCuring), + 15 => Box::new(ChimeTemplate::ChimeOfDispelEvil), + 16 => Box::new(ChimeTemplate::ChimeOfDarkness), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for ChimeTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Chime } fn flags1(&self) -> u64 { 0 } diff --git a/src/item_template/cloak.rs b/src/item_template/cloak.rs index f06e672e..5c22fb61 100644 --- a/src/item_template/cloak.rs +++ b/src/item_template/cloak.rs @@ -24,19 +24,20 @@ impl CloakTemplate { pub fn iter() -> impl Iterator> { CloakTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for CloakTemplate { - fn name(&self) -> &str { - match self { - CloakTemplate::LightCloak => "Light Cloak^ [%P6,%P4]", - CloakTemplate::HeavyCloak => "Heavy Cloak^ [%P6,%P4]", - CloakTemplate::SharkskinCloak => "Sharkskin Cloak^ [%P6,%P4]", - CloakTemplate::DemonhideCloak => "Demonhide Cloak^ [%P6,%P4]", - CloakTemplate::WyrmhideCloak => "Wyrmhide Cloak^ [%P6,%P4]", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(CloakTemplate::LightCloak), + 2 => Box::new(CloakTemplate::HeavyCloak), + 3 => Box::new(CloakTemplate::SharkskinCloak), + 4 => Box::new(CloakTemplate::DemonhideCloak), + 5 => Box::new(CloakTemplate::WyrmhideCloak), + _ => panic!("subval {} out of bounds", subval), } } +} + +impl item_template::ItemTemplate for CloakTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Bracers } diff --git a/src/item_template/crossbow.rs b/src/item_template/crossbow.rs index be1385a8..53588231 100644 --- a/src/item_template/crossbow.rs +++ b/src/item_template/crossbow.rs @@ -23,19 +23,20 @@ impl CrossbowTemplate { pub fn iter() -> impl Iterator> { CrossbowTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for CrossbowTemplate { - fn name(&self) -> &str { - match self { - CrossbowTemplate::SiegeCrossbow => "Siege Crossbow (%P0)^ (%P2,%P3)", - CrossbowTemplate::Ballista => "Ballista (%P0)^ (%P2,%P3)", - CrossbowTemplate::LightCrossbow => "Light Crossbow (%P0)^ (%P2,%P3)", - CrossbowTemplate::HeavyCrossbow => "Heavy Crossbow (%P0)^ (%P2,%P3)", - } + pub fn from(subval: i64) -> Box { + match subval { + 10 => Box::new(CrossbowTemplate::SiegeCrossbow), + 11 => Box::new(CrossbowTemplate::Ballista), + 12 => Box::new(CrossbowTemplate::LightCrossbow), + 13 => Box::new(CrossbowTemplate::HeavyCrossbow), + _ => panic!("subval {} out of bounds", subval), + } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::RangedWeapon } +impl item_template::ItemTemplate for CrossbowTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Crossbow } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } @@ -62,7 +63,7 @@ impl item_template::ItemTemplate for CrossbowTemplate { CrossbowTemplate::SiegeCrossbow => 10, CrossbowTemplate::Ballista => 11, CrossbowTemplate::LightCrossbow => 12, - CrossbowTemplate::HeavyCrossbow => 12, + CrossbowTemplate::HeavyCrossbow => 13, } } diff --git a/src/item_template/dagger.rs b/src/item_template/dagger.rs index 7bd0617f..97fead27 100644 --- a/src/item_template/dagger.rs +++ b/src/item_template/dagger.rs @@ -37,26 +37,26 @@ impl DaggerTemplate { pub fn iter() -> impl Iterator> { DaggerTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for DaggerTemplate { - fn name(&self) -> &str { - match self { - DaggerTemplate::MainGauche =>"Main Gauche (%P0)^ (%P2,%P3)", - DaggerTemplate::Misercorde =>"Misercorde (%P0)^ (%P2,%P3)", - DaggerTemplate::Stiletto =>"Stiletto (%P0)^ (%P2,%P3)", - DaggerTemplate::Bodkin =>"Bodkin (%P0)^ (%P2,%P3)", - DaggerTemplate::BrokenDagger =>"Broken Dagger (%P0)^ (%P2,%P3)", - DaggerTemplate::CatONineTails =>"Cat-O-Nine Tails (%P0)^ (%P2,%P3)", - DaggerTemplate::Bilbo =>"Bilbo (%P0)^ (%P2,%P3)", - DaggerTemplate::Baselard =>"Baselard (%P0)^ (%P2,%P3)", - DaggerTemplate::Foil =>"Foil (%P0)^ (%P2,%P3)", - DaggerTemplate::Rapier =>"Rapier (%P0)^ (%P2,%P3)", - DaggerTemplate::SmallSword =>"Small Sword (%P0)^ (%P2,%P3)", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(DaggerTemplate::MainGauche), + 2 => Box::new(DaggerTemplate::Misercorde), + 3 => Box::new(DaggerTemplate::Stiletto), + 4 => Box::new(DaggerTemplate::Bodkin), + 6 => Box::new(DaggerTemplate::BrokenDagger), + 5 => Box::new(DaggerTemplate::CatONineTails), + 8 => Box::new(DaggerTemplate::Bilbo), + 9 => Box::new(DaggerTemplate::Baselard), + 16 => Box::new(DaggerTemplate::Foil), + 20 => Box::new(DaggerTemplate::Rapier), + 22 => Box::new(DaggerTemplate::SmallSword), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for DaggerTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Dagger } fn flags1(&self) -> u64 { 0x10000000 } fn flags2(&self) -> u64 { 0 } @@ -84,7 +84,7 @@ impl item_template::ItemTemplate for DaggerTemplate { DaggerTemplate::Misercorde => 2, DaggerTemplate::Stiletto => 3, DaggerTemplate::Bodkin => 4, - DaggerTemplate::BrokenDagger => 5, + DaggerTemplate::BrokenDagger => 6, DaggerTemplate::CatONineTails => 5, DaggerTemplate::Bilbo => 8, DaggerTemplate::Baselard => 9, diff --git a/src/item_template/dungeon_feature.rs b/src/item_template/dungeon_feature.rs new file mode 100644 index 00000000..cf43e514 --- /dev/null +++ b/src/item_template/dungeon_feature.rs @@ -0,0 +1,105 @@ +use model; +use item_template; + +#[derive(Copy, Clone, Eq, PartialEq, Hash)] +pub enum DungeonFeatureTemplate { + Money, + UnseenTrap, + SeenTrap, + Rubble, + OpenDoor, + ClosedDoor, + UpStaircase, + DownStaircase, + SecretDoor, + EntranceToStore, + UpSteepStaircase, + DownSteepStaircase, + Whirlpool, +} + +impl DungeonFeatureTemplate { + pub fn vec() -> Vec> { + vec![ + Box::new(DungeonFeatureTemplate::Money), + Box::new(DungeonFeatureTemplate::UnseenTrap), + Box::new(DungeonFeatureTemplate::SeenTrap), + Box::new(DungeonFeatureTemplate::Rubble), + Box::new(DungeonFeatureTemplate::OpenDoor), + Box::new(DungeonFeatureTemplate::ClosedDoor), + Box::new(DungeonFeatureTemplate::UpStaircase), + Box::new(DungeonFeatureTemplate::DownStaircase), + Box::new(DungeonFeatureTemplate::SecretDoor), + Box::new(DungeonFeatureTemplate::EntranceToStore), + Box::new(DungeonFeatureTemplate::UpSteepStaircase), + Box::new(DungeonFeatureTemplate::DownSteepStaircase), + Box::new(DungeonFeatureTemplate::Whirlpool), + ] + } + + pub fn iter() -> impl Iterator> { + DungeonFeatureTemplate::vec().into_iter() + } + + pub fn from(subval: i64) -> Box { + match subval { + _ => panic!("subval {} out of bounds", subval), + } + } +} + +impl item_template::ItemTemplate for DungeonFeatureTemplate { + fn item_type(&self) -> model::ItemType { + match self { + DungeonFeatureTemplate::Money => model::ItemType::Money, + DungeonFeatureTemplate::UnseenTrap => model::ItemType::UnseenTrap, + DungeonFeatureTemplate::SeenTrap => model::ItemType::SeenTrap, + DungeonFeatureTemplate::Rubble => model::ItemType::Rubble, + DungeonFeatureTemplate::OpenDoor => model::ItemType::OpenDoor, + DungeonFeatureTemplate::ClosedDoor => model::ItemType::ClosedDoor, + DungeonFeatureTemplate::UpStaircase => model::ItemType::UpStaircase, + DungeonFeatureTemplate::DownStaircase => model::ItemType::DownStaircase, + DungeonFeatureTemplate::SecretDoor => model::ItemType::SecretDoor, + DungeonFeatureTemplate::EntranceToStore => model::ItemType::EntranceToStore, + DungeonFeatureTemplate::UpSteepStaircase => model::ItemType::UpSteepStaircase, + DungeonFeatureTemplate::DownSteepStaircase => model::ItemType::DownSteepStaircase, + DungeonFeatureTemplate::Whirlpool => model::ItemType::Whirlpool, + } + } + fn flags1(&self) -> u64 { 0 } + fn flags2(&self) -> u64 { 0 } + fn p1(&self) -> i64 { 0 } + fn cost(&self) -> i64 { 0 } + + fn subtype(&self) -> i64 { + match self { + DungeonFeatureTemplate::Money => 0, + DungeonFeatureTemplate::UnseenTrap => 0, + DungeonFeatureTemplate::SeenTrap => 0, + DungeonFeatureTemplate::Rubble => 0, + DungeonFeatureTemplate::OpenDoor => 1, + DungeonFeatureTemplate::ClosedDoor => 19, + DungeonFeatureTemplate::UpStaircase => 0, + DungeonFeatureTemplate::DownStaircase => 0, + DungeonFeatureTemplate::SecretDoor => 19, + DungeonFeatureTemplate::EntranceToStore => 0, + DungeonFeatureTemplate::UpSteepStaircase => 0, + DungeonFeatureTemplate::DownSteepStaircase => 0, + DungeonFeatureTemplate::Whirlpool => 0, + } + } + + fn weight(&self) -> u16 { 0 } + + fn number(&self) -> u16 { 0 } + fn modifier_to_hit(&self) -> i16 { 0 } + fn modifier_to_damage(&self) -> i16 { 0 } + fn base_ac(&self) -> i16 { 0 } + fn modifier_to_ac(&self) -> i16 { 0 } + fn damage(&self) -> &str { "1d1" } + fn item_level(&self) -> u8 { 0 } + fn is_identified(&self) -> bool { true } +} + + + diff --git a/src/item_template/food.rs b/src/item_template/food.rs index c35892ab..3000474f 100644 --- a/src/item_template/food.rs +++ b/src/item_template/food.rs @@ -34,13 +34,10 @@ pub enum FoodTemplate { FineWine, ElvishWaybread, Stew, - JollyGreenJelly, GreenJelly, BerriesPoisonous, BerriesSmurfberries, - BerriesSmurfberries2, BerriesGoodberries, - BerriesGoodberries2, EyeballOfNed, } @@ -78,13 +75,10 @@ impl FoodTemplate { Box::new(FoodTemplate::FineWine), Box::new(FoodTemplate::ElvishWaybread), Box::new(FoodTemplate::Stew), - Box::new(FoodTemplate::JollyGreenJelly), Box::new(FoodTemplate::GreenJelly), Box::new(FoodTemplate::BerriesPoisonous), Box::new(FoodTemplate::BerriesSmurfberries), - Box::new(FoodTemplate::BerriesSmurfberries2), Box::new(FoodTemplate::BerriesGoodberries), - Box::new(FoodTemplate::BerriesGoodberries2), Box::new(FoodTemplate::EyeballOfNed), ] } @@ -92,53 +86,51 @@ impl FoodTemplate { pub fn iter() -> impl Iterator> { FoodTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for FoodTemplate { - fn name(&self) -> &str { - match self { - FoodTemplate::Mushroom => "& Mushroom~", - FoodTemplate::MushroomOfPoison => "& Mushroom~| of Poison", - FoodTemplate::MushroomOfBlindness => "& Mushroom~| of Blindness", - FoodTemplate::MushroomOfParanoia => "& Mushroom~| of Paranoia", - FoodTemplate::MushroomOfConfusion => "& Mushroom~| of Confusion", - FoodTemplate::MushroomOfHallucination => "& Mushroom~| of Hallucination", - FoodTemplate::MushroomOfCurePoison => "& Mushroom~| of Cure Poison", - FoodTemplate::MushroomOfCureBlindness => "& Mushroom~| of Cure Blindness", - FoodTemplate::MushroomOfCureParanoia => "& Mushroom~| of Cure Paranoia", - FoodTemplate::MushroomOfCureConfusion => "& Mushroom~| of Cure Confusion", - FoodTemplate::MushroomOfWeakness => "& Mushroom~| of Weakness", - FoodTemplate::MushroomOfUnhealth => "& Mushroom~| of Unhealth", - FoodTemplate::MushroomOfRestoreConstitution => "& Mushroom~| of Restore Constitution", - FoodTemplate::MushroomOfFirstAid => "& Mushroom~| of First-Aid", - FoodTemplate::MushroomOfMinorCures => "& Mushroom~| of Minor Cures", - FoodTemplate::MushroomOfLightCures => "& Mushroom~| of Light Cures", - FoodTemplate::MushroomOfRestoring => "& Mushroom~| of Restoring", - FoodTemplate::MushroomOfPoison2 => "& Mushroom~| of Poison", - FoodTemplate::MushroomOfHallucination2 => "& Mushroom~| of Hallucination", - FoodTemplate::MushroomOfCurePoison2 => "& Mushroom~| of Cure Poison", - FoodTemplate::MushroomOfUnhealth2 => "& Mushroom~| of Unhealth", - FoodTemplate::MushroomOfCureSeriousWounds => "& Mushroom~| of Cure Serious Wounds", - FoodTemplate::PintOfFineGradeMush => "& pint~ of fine grade mush", - FoodTemplate::RationOfFood => "& Ration~ of Food", - FoodTemplate::Mushroom2 => "& Mushroom~", - FoodTemplate::HardBiscuit => "& Hard Biscuit~", - FoodTemplate::BeefJerky => "& Strip~ of Beef Jerky", - FoodTemplate::FineAle => "& Pint~ of Fine Ale", - FoodTemplate::FineWine => "& Pint~ of Fine Wine", - FoodTemplate::ElvishWaybread => "& Piece~ of Elvish Waybread", - FoodTemplate::Stew => "& Stew~", - FoodTemplate::JollyGreenJelly => "& Jolly Green Jelly~| (Ho Ho Ho!)", - FoodTemplate::GreenJelly => "& Green Jelly~", - FoodTemplate::BerriesPoisonous => "& Handful~ of Berries| (Poisonous)", - FoodTemplate::BerriesSmurfberries => "& Handful~ of Berries| (Smurfberries)", - FoodTemplate::BerriesSmurfberries2 => "& Handful~ of Berries| (Smurfberries)", - FoodTemplate::BerriesGoodberries => "& Handful~ of Berries| (Goodberries)", - FoodTemplate::BerriesGoodberries2 => "& Handful~ of Berries| (Goodberries)", - FoodTemplate::EyeballOfNed => "& Eyeball~| of Ned", + pub fn from(subval: i64) -> Box { + match subval { + 256 => Box::new(FoodTemplate::Mushroom), + 257 => Box::new(FoodTemplate::MushroomOfPoison), + 258 => Box::new(FoodTemplate::MushroomOfBlindness), + 259 => Box::new(FoodTemplate::MushroomOfParanoia), + 260 => Box::new(FoodTemplate::MushroomOfConfusion), + 261 => Box::new(FoodTemplate::MushroomOfHallucination), + 262 => Box::new(FoodTemplate::MushroomOfCurePoison), + 263 => Box::new(FoodTemplate::MushroomOfCureBlindness), + 264 => Box::new(FoodTemplate::MushroomOfCureParanoia), + 265 => Box::new(FoodTemplate::MushroomOfCureConfusion), + 266 => Box::new(FoodTemplate::MushroomOfWeakness), + 267 => Box::new(FoodTemplate::MushroomOfUnhealth), + 268 => Box::new(FoodTemplate::MushroomOfRestoreConstitution), + 269 => Box::new(FoodTemplate::MushroomOfFirstAid), + 270 => Box::new(FoodTemplate::MushroomOfMinorCures), + 271 => Box::new(FoodTemplate::MushroomOfLightCures), + 272 => Box::new(FoodTemplate::MushroomOfRestoring), + 273 => Box::new(FoodTemplate::MushroomOfPoison2), + 274 => Box::new(FoodTemplate::MushroomOfHallucination2), + 275 => Box::new(FoodTemplate::MushroomOfCurePoison2), + 276 => Box::new(FoodTemplate::MushroomOfUnhealth2), + 277 => Box::new(FoodTemplate::MushroomOfCureSeriousWounds), + 306 => Box::new(FoodTemplate::PintOfFineGradeMush), + 307 => Box::new(FoodTemplate::RationOfFood), + 308 => Box::new(FoodTemplate::Mushroom2), + 309 => Box::new(FoodTemplate::HardBiscuit), + 310 => Box::new(FoodTemplate::BeefJerky), + 311 => Box::new(FoodTemplate::FineAle), + 312 => Box::new(FoodTemplate::FineWine), + 313 => Box::new(FoodTemplate::ElvishWaybread), + 314 => Box::new(FoodTemplate::Stew), + 315 => Box::new(FoodTemplate::GreenJelly), + 316 => Box::new(FoodTemplate::BerriesPoisonous), + 317 => Box::new(FoodTemplate::BerriesSmurfberries), + 318 => Box::new(FoodTemplate::BerriesGoodberries), + 319 => Box::new(FoodTemplate::EyeballOfNed), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for FoodTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Food } fn flags1(&self) -> u64 { 0 } @@ -175,13 +167,10 @@ impl item_template::ItemTemplate for FoodTemplate { FoodTemplate::FineWine => 0, FoodTemplate::ElvishWaybread => 0x21800020, FoodTemplate::Stew => 0x330001C0, - FoodTemplate::JollyGreenJelly => 0x224001C0, FoodTemplate::GreenJelly => 0x22400060, FoodTemplate::BerriesPoisonous => 0x0C0000000, FoodTemplate::BerriesSmurfberries => 0x10400000, - FoodTemplate::BerriesSmurfberries2 => 0x30400000, FoodTemplate::BerriesGoodberries => 0x10C00080, - FoodTemplate::BerriesGoodberries2 => 0x30C00080, FoodTemplate::EyeballOfNed => 0x00000053, } @@ -220,13 +209,10 @@ impl item_template::ItemTemplate for FoodTemplate { FoodTemplate::FineWine => 400, FoodTemplate::ElvishWaybread => 3500, FoodTemplate::Stew => 2000, - FoodTemplate::JollyGreenJelly => 4000, FoodTemplate::GreenJelly => 4000, FoodTemplate::BerriesPoisonous => 1000, FoodTemplate::BerriesSmurfberries => 1000, - FoodTemplate::BerriesSmurfberries2 => 1000, FoodTemplate::BerriesGoodberries => 1000, - FoodTemplate::BerriesGoodberries2 => 1000, FoodTemplate::EyeballOfNed => 200, } @@ -265,13 +251,10 @@ impl item_template::ItemTemplate for FoodTemplate { FoodTemplate::FineWine => 2, FoodTemplate::ElvishWaybread => 10, FoodTemplate::Stew => 0, - FoodTemplate::JollyGreenJelly => 0, FoodTemplate::GreenJelly => 50, FoodTemplate::BerriesPoisonous => 0, FoodTemplate::BerriesSmurfberries => 0, - FoodTemplate::BerriesSmurfberries2 => 0, FoodTemplate::BerriesGoodberries => 0, - FoodTemplate::BerriesGoodberries2 => 0, FoodTemplate::EyeballOfNed => 50, } } @@ -309,13 +292,10 @@ impl item_template::ItemTemplate for FoodTemplate { FoodTemplate::FineWine => 312, FoodTemplate::ElvishWaybread => 313, FoodTemplate::Stew => 314, - FoodTemplate::JollyGreenJelly => 315, FoodTemplate::GreenJelly => 315, FoodTemplate::BerriesPoisonous => 316, FoodTemplate::BerriesSmurfberries => 317, - FoodTemplate::BerriesSmurfberries2 => 317, FoodTemplate::BerriesGoodberries => 318, - FoodTemplate::BerriesGoodberries2 => 318, FoodTemplate::EyeballOfNed => 319, } } @@ -353,13 +333,10 @@ impl item_template::ItemTemplate for FoodTemplate { FoodTemplate::FineWine => 10, FoodTemplate::ElvishWaybread => 3, FoodTemplate::Stew => 3, - FoodTemplate::JollyGreenJelly => 3, FoodTemplate::GreenJelly => 3, FoodTemplate::BerriesPoisonous => 3, FoodTemplate::BerriesSmurfberries => 3, - FoodTemplate::BerriesSmurfberries2 => 3, FoodTemplate::BerriesGoodberries => 3, - FoodTemplate::BerriesGoodberries2 => 3, FoodTemplate::EyeballOfNed => 2, } @@ -398,13 +375,10 @@ impl item_template::ItemTemplate for FoodTemplate { FoodTemplate::FineWine => 1, FoodTemplate::ElvishWaybread => 1, FoodTemplate::Stew => 1, - FoodTemplate::JollyGreenJelly => 1, FoodTemplate::GreenJelly => 1, FoodTemplate::BerriesPoisonous => 1, FoodTemplate::BerriesSmurfberries => 1, - FoodTemplate::BerriesSmurfberries2 => 1, FoodTemplate::BerriesGoodberries => 1, - FoodTemplate::BerriesGoodberries2 => 1, FoodTemplate::EyeballOfNed => 2, } @@ -448,13 +422,10 @@ impl item_template::ItemTemplate for FoodTemplate { FoodTemplate::FineWine => "0d0", FoodTemplate::ElvishWaybread => "0d0", FoodTemplate::Stew => "0d0", - FoodTemplate::JollyGreenJelly => "0d0", FoodTemplate::GreenJelly => "0d0", FoodTemplate::BerriesPoisonous => "0d0", FoodTemplate::BerriesSmurfberries => "0d0", - FoodTemplate::BerriesSmurfberries2 => "0d0", FoodTemplate::BerriesGoodberries => "0d0", - FoodTemplate::BerriesGoodberries2 => "0d0", FoodTemplate::EyeballOfNed => "6d5", } @@ -493,13 +464,10 @@ impl item_template::ItemTemplate for FoodTemplate { FoodTemplate::FineWine => 9, FoodTemplate::ElvishWaybread => 7, FoodTemplate::Stew => 15, - FoodTemplate::JollyGreenJelly => 20, FoodTemplate::GreenJelly => 30, FoodTemplate::BerriesPoisonous => 15, FoodTemplate::BerriesSmurfberries => 28, - FoodTemplate::BerriesSmurfberries2 => 7, FoodTemplate::BerriesGoodberries => 255, - FoodTemplate::BerriesGoodberries2 => 0, FoodTemplate::EyeballOfNed => 255, } } diff --git a/src/item_template/gem.rs b/src/item_template/gem.rs new file mode 100644 index 00000000..0fc74143 --- /dev/null +++ b/src/item_template/gem.rs @@ -0,0 +1,242 @@ +use model; +use item_template; + +#[derive(Copy, Clone, Eq, PartialEq, Hash)] +pub enum GemTemplate { + GemOfDetectMonsters, + GemOfDispelEvil, + GemOfDarkness, + GemOfAcidBalls, + GemOfDetectInvisible, + GemOfIdentify, + GemOfLight, + GemOfSummoning, + GemOfRemoveCurse, + GemOfAnnihilation, + GemOfRecall, + FineAgate, + FineDiamond, + RoughDiamond, + RoughSapphire, + FineSapphire, + SmallBagOfOpals, + SmallBagOfSapphires, + SmallPouchOfDiamonds, + LargeSackOfPearls, + LargeSackOfSapphires, + LargePouchOfDiamonds, +} + +impl GemTemplate { + pub fn vec() -> Vec> { + vec![ + Box::new(GemTemplate::GemOfDetectMonsters), + Box::new(GemTemplate::GemOfDispelEvil), + Box::new(GemTemplate::GemOfDarkness), + Box::new(GemTemplate::GemOfAcidBalls), + Box::new(GemTemplate::GemOfDetectInvisible), + Box::new(GemTemplate::GemOfIdentify), + Box::new(GemTemplate::GemOfLight), + Box::new(GemTemplate::GemOfSummoning), + Box::new(GemTemplate::GemOfRemoveCurse), + Box::new(GemTemplate::GemOfAnnihilation), + Box::new(GemTemplate::GemOfRecall), + Box::new(GemTemplate::FineAgate), + Box::new(GemTemplate::FineDiamond), + Box::new(GemTemplate::RoughDiamond), + Box::new(GemTemplate::RoughSapphire), + Box::new(GemTemplate::FineSapphire), + Box::new(GemTemplate::SmallBagOfOpals), + Box::new(GemTemplate::SmallBagOfSapphires), + Box::new(GemTemplate::SmallPouchOfDiamonds), + Box::new(GemTemplate::LargeSackOfPearls), + Box::new(GemTemplate::LargeSackOfSapphires), + Box::new(GemTemplate::LargePouchOfDiamonds), + ] + } + + pub fn iter() -> impl Iterator> { + GemTemplate::vec().into_iter() + } + + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(GemTemplate::GemOfDetectMonsters), + 2 => Box::new(GemTemplate::GemOfDispelEvil), + 3 => Box::new(GemTemplate::GemOfDarkness), + 4 => Box::new(GemTemplate::GemOfAcidBalls), + 5 => Box::new(GemTemplate::GemOfDetectInvisible), + 6 => Box::new(GemTemplate::GemOfIdentify), + 7 => Box::new(GemTemplate::GemOfLight), + 8 => Box::new(GemTemplate::GemOfSummoning), + 9 => Box::new(GemTemplate::GemOfRemoveCurse), + 10 => Box::new(GemTemplate::GemOfAnnihilation), + 11 => Box::new(GemTemplate::GemOfRecall), + 257 => Box::new(GemTemplate::FineAgate), + 258 => Box::new(GemTemplate::FineDiamond), + 259 => Box::new(GemTemplate::RoughDiamond), + 260 => Box::new(GemTemplate::RoughSapphire), + 261 => Box::new(GemTemplate::FineSapphire), + 262 => Box::new(GemTemplate::SmallBagOfOpals), + 263 => Box::new(GemTemplate::SmallBagOfSapphires), + 264 => Box::new(GemTemplate::SmallPouchOfDiamonds), + 265 => Box::new(GemTemplate::LargeSackOfPearls), + 266 => Box::new(GemTemplate::LargeSackOfSapphires), + 267 => Box::new(GemTemplate::LargePouchOfDiamonds), + _ => panic!("subval {} out of bounds", subval), + } + } +} + +impl item_template::ItemTemplate for GemTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Gem } + + fn flags1(&self) -> u64 { 0 } + + fn flags2(&self) -> u64 { + match self { + GemTemplate::GemOfDetectMonsters => 0x00040000, + GemTemplate::GemOfDispelEvil => 0x00080000, + GemTemplate::GemOfDarkness => 0x00100000, + GemTemplate::GemOfAcidBalls => 0x00200000, + GemTemplate::GemOfDetectInvisible => 0x00400000, + GemTemplate::GemOfIdentify => 0x00800000, + GemTemplate::GemOfLight => 0x01000000, + GemTemplate::GemOfSummoning => 0x02000000, + GemTemplate::GemOfRemoveCurse => 0x04000000, + GemTemplate::GemOfAnnihilation => 0x08000000, + GemTemplate::GemOfRecall => 0x10000000, + GemTemplate::FineAgate => 0, + GemTemplate::FineDiamond => 0, + GemTemplate::RoughDiamond => 0, + GemTemplate::RoughSapphire => 0, + GemTemplate::FineSapphire => 0, + GemTemplate::SmallBagOfOpals => 0, + GemTemplate::SmallBagOfSapphires => 0, + GemTemplate::SmallPouchOfDiamonds => 0, + GemTemplate::LargeSackOfPearls => 0, + GemTemplate::LargeSackOfSapphires => 0, + GemTemplate::LargePouchOfDiamonds => 0, + } + } + + fn p1(&self) -> i64 { 0 } + + fn cost(&self) -> i64 { + match self { + GemTemplate::GemOfDetectMonsters => 350, + GemTemplate::GemOfDispelEvil => 1200, + GemTemplate::GemOfDarkness => 0, + GemTemplate::GemOfAcidBalls => 1800, + GemTemplate::GemOfDetectInvisible => 225, + GemTemplate::GemOfIdentify => 400, + GemTemplate::GemOfLight => 300, + GemTemplate::GemOfSummoning => 0, + GemTemplate::GemOfRemoveCurse => 700, + GemTemplate::GemOfAnnihilation => 1000, + GemTemplate::GemOfRecall => 1200, + GemTemplate::FineAgate => 50, + GemTemplate::FineDiamond => 500, + GemTemplate::RoughDiamond => 100, + GemTemplate::RoughSapphire => 40, + GemTemplate::FineSapphire => 250, + GemTemplate::SmallBagOfOpals => 250, + GemTemplate::SmallBagOfSapphires => 450, + GemTemplate::SmallPouchOfDiamonds => 1000, + GemTemplate::LargeSackOfPearls => 650, + GemTemplate::LargeSackOfSapphires => 600, + GemTemplate::LargePouchOfDiamonds => 2000, + } + } + + fn subtype(&self) -> i64 { + match self { + GemTemplate::GemOfDetectMonsters => 1, + GemTemplate::GemOfDispelEvil => 2, + GemTemplate::GemOfDarkness => 3, + GemTemplate::GemOfAcidBalls => 4, + GemTemplate::GemOfDetectInvisible => 5, + GemTemplate::GemOfIdentify => 6, + GemTemplate::GemOfLight => 7, + GemTemplate::GemOfSummoning => 8, + GemTemplate::GemOfRemoveCurse => 9, + GemTemplate::GemOfAnnihilation => 10, + GemTemplate::GemOfRecall => 11, + GemTemplate::FineAgate => 257, + GemTemplate::FineDiamond => 258, + GemTemplate::RoughDiamond => 259, + GemTemplate::RoughSapphire => 260, + GemTemplate::FineSapphire => 261, + GemTemplate::SmallBagOfOpals => 262, + GemTemplate::SmallBagOfSapphires => 263, + GemTemplate::SmallPouchOfDiamonds => 264, + GemTemplate::LargeSackOfPearls => 265, + GemTemplate::LargeSackOfSapphires => 266, + GemTemplate::LargePouchOfDiamonds => 267, + } + } + + fn weight(&self) -> u16 { + match self { + GemTemplate::GemOfDetectMonsters => 5, + GemTemplate::GemOfDispelEvil => 5, + GemTemplate::GemOfDarkness => 5, + GemTemplate::GemOfAcidBalls => 5, + GemTemplate::GemOfDetectInvisible => 5, + GemTemplate::GemOfIdentify => 5, + GemTemplate::GemOfLight => 5, + GemTemplate::GemOfSummoning => 5, + GemTemplate::GemOfRemoveCurse => 5, + GemTemplate::GemOfAnnihilation => 5, + GemTemplate::GemOfRecall => 5, + GemTemplate::FineAgate => 5, + GemTemplate::FineDiamond => 5, + GemTemplate::RoughDiamond => 5, + GemTemplate::RoughSapphire => 5, + GemTemplate::FineSapphire => 5, + GemTemplate::SmallBagOfOpals => 5, + GemTemplate::SmallBagOfSapphires => 5, + GemTemplate::SmallPouchOfDiamonds => 5, + GemTemplate::LargeSackOfPearls => 35, + GemTemplate::LargeSackOfSapphires => 5, + GemTemplate::LargePouchOfDiamonds => 5, + } + } + + fn number(&self) -> u16 { 1 } + fn modifier_to_hit(&self) -> i16 { 0 } + fn modifier_to_damage(&self) -> i16 { 0 } + fn base_ac(&self) -> i16 { 0 } + fn modifier_to_ac(&self) -> i16 { 0 } + fn damage(&self) -> &str { "1d1" } + + fn item_level(&self) -> u8 { + match self { + GemTemplate::GemOfDetectMonsters => 14, + GemTemplate::GemOfDispelEvil => 49, + GemTemplate::GemOfDarkness => 7, + GemTemplate::GemOfAcidBalls => 50, + GemTemplate::GemOfDetectInvisible => 47, + GemTemplate::GemOfIdentify => 40, + GemTemplate::GemOfLight => 2, + GemTemplate::GemOfSummoning => 3, + GemTemplate::GemOfRemoveCurse => 25, + GemTemplate::GemOfAnnihilation => 40, + GemTemplate::GemOfRecall => 22, + GemTemplate::FineAgate => 5, + GemTemplate::FineDiamond => 35, + GemTemplate::RoughDiamond => 15, + GemTemplate::RoughSapphire => 7, + GemTemplate::FineSapphire => 12, + GemTemplate::SmallBagOfOpals => 10, + GemTemplate::SmallBagOfSapphires => 15, + GemTemplate::SmallPouchOfDiamonds => 45, + GemTemplate::LargeSackOfPearls => 25, + GemTemplate::LargeSackOfSapphires => 30, + GemTemplate::LargePouchOfDiamonds => 65, + } + } + + fn is_identified(&self) -> bool { false } +} + diff --git a/src/item_template/gloves.rs b/src/item_template/gloves.rs index 8eb797b8..187728f6 100644 --- a/src/item_template/gloves.rs +++ b/src/item_template/gloves.rs @@ -34,25 +34,25 @@ impl GlovesTemplate { pub fn iter() -> impl Iterator> { GlovesTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for GlovesTemplate { - fn name(&self) -> &str { - match self { - GlovesTemplate::LeatherGloves => "Leather Gloves^ [%P6,%P4]", - GlovesTemplate::HeavyGloves => "Heavy Gloves^ [%P6,%P4]", - GlovesTemplate::ClothGloves => "Cloth Gloves^ [%P6,%P4]", - GlovesTemplate::ChainGloves => "Chain Gloves^ [%P6,%P4]", - GlovesTemplate::LightGauntlets => "Light Gauntlets^ [%P6,%P4]", - GlovesTemplate::HeavyGauntlets => "Heavy Gauntlets^ [%P6,%P4]", - GlovesTemplate::SharkskinGloves => "Sharkskin Gloves^ [%P6,%P4]", - GlovesTemplate::WarGauntlets => "War Gauntlets^ [%P6,%P4]", - GlovesTemplate::DemonhideGloves => "Demonhide Gloves^ [%P6,%P4]", - GlovesTemplate::WyrmhideGloves => "Wyrmhide Gloves^ [%P6,%P4]", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(GlovesTemplate::LeatherGloves), + 2 => Box::new(GlovesTemplate::HeavyGloves), + 5 => Box::new(GlovesTemplate::ClothGloves), + 6 => Box::new(GlovesTemplate::ChainGloves), + 7 => Box::new(GlovesTemplate::LightGauntlets), + 8 => Box::new(GlovesTemplate::HeavyGauntlets), + 9 => Box::new(GlovesTemplate::SharkskinGloves), + 10 => Box::new(GlovesTemplate::WarGauntlets), + 11 => Box::new(GlovesTemplate::DemonhideGloves), + 12 => Box::new(GlovesTemplate::WyrmhideGloves), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for GlovesTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Gloves } diff --git a/src/item_template/helm.rs b/src/item_template/helm.rs index 82433667..a5880f7e 100644 --- a/src/item_template/helm.rs +++ b/src/item_template/helm.rs @@ -38,26 +38,27 @@ impl HelmTemplate { pub fn iter() -> impl Iterator> { HelmTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for HelmTemplate { - fn name(&self) -> &str { - match self { - HelmTemplate::ClothHat => "Cloth Hat^ [%P6,%P4]", - HelmTemplate::SoftLeatherCap => "Soft Leather Cap^ [%P6,%P4]", - HelmTemplate::HardLeatherCap => "Hard Leather Cap^ [%P6,%P4]", - HelmTemplate::MetalCap => "Metal Cap^ [%P6,%P4]", - HelmTemplate::FullHelm => "Full Helm^ [%P6,%P4]", - HelmTemplate::GreatHelm => "Great Helm^ [%P6,%P4]", - HelmTemplate::WingedHelm => "Winged Helm^ [%P6,%P4]", - HelmTemplate::SilverCrown => "Silver Crown^ [%P6,%P4] (%P1)", - HelmTemplate::SilverMask => "Silver Mask^ [%P6,%P4] (%P1)", - HelmTemplate::GoldenCrown => "Golden Crown^ [%P6,%P4] (%P1)", - HelmTemplate::GoldenMask => "Golden Mask^ [%P6,%P4] (%P1)", - HelmTemplate::JewelEncrustedCrown => "Jewel Encrusted Crown^ [%P6,%P4] (%P1)", + pub fn from(subval: i64) -> Box { + match subval { + 12 => Box::new(HelmTemplate::ClothHat), + 13 => Box::new(HelmTemplate::SoftLeatherCap), + 14 => Box::new(HelmTemplate::HardLeatherCap), + 15 => Box::new(HelmTemplate::MetalCap), + 16 => Box::new(HelmTemplate::FullHelm), + 17 => Box::new(HelmTemplate::GreatHelm), + 18 => Box::new(HelmTemplate::WingedHelm), + 19 => Box::new(HelmTemplate::SilverCrown), + 20 => Box::new(HelmTemplate::SilverMask), + 21 => Box::new(HelmTemplate::GoldenCrown), + 22 => Box::new(HelmTemplate::GoldenMask), + 23 => Box::new(HelmTemplate::JewelEncrustedCrown), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for HelmTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Helm } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/horn.rs b/src/item_template/horn.rs index 3ff928eb..40c0d116 100644 --- a/src/item_template/horn.rs +++ b/src/item_template/horn.rs @@ -40,27 +40,28 @@ impl HornTemplate { pub fn iter() -> impl Iterator> { HornTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for HornTemplate { - fn name(&self) -> &str { - match self { - HornTemplate::HornOfBubbles => "& Horn| of Bubbles^ (%P1 charges)", - HornTemplate::HornOfCalling => "& Horn| of Calling^ (%P1 charges)", - HornTemplate::HornOfSoftSounds => "& Horn| of Soft Sounds^ (%P1 charges)", - HornTemplate::HornOfBlasting => "& Horn| of *Blasting*^ (%P1 charges)", - HornTemplate::HornOfCold => "& Horn| of Cold^ (%P1 charges)", - HornTemplate::HornOfHeat => "& Horn| of Heat^ (%P1 charges)", - HornTemplate::HornOfGas => "& Horn| of Gas^ (%P1 charges)", - HornTemplate::HornOfRecall => "& Horn| of Recall^ (%P1 charges)", - HornTemplate::HornOfChaos => "& Horn| of *Chaos*^ (%P1 charges)", - HornTemplate::HornOfGlue => "& Horn| of Glue^ (%P1 charges)", - HornTemplate::HornOfValhalla => "& Horn| of Valhalla^ (%P1 charges)", - HornTemplate::HornOfTritons => "& Horn| of Tritons^ (%P1 charges)", - HornTemplate::HornOfFog => "& Horn| of Fog^ (%P1 charges)", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(HornTemplate::HornOfBubbles), + 2 => Box::new(HornTemplate::HornOfCalling), + 3 => Box::new(HornTemplate::HornOfSoftSounds), + 4 => Box::new(HornTemplate::HornOfBlasting), + 5 => Box::new(HornTemplate::HornOfCold), + 6 => Box::new(HornTemplate::HornOfHeat), + 7 => Box::new(HornTemplate::HornOfGas), + 8 => Box::new(HornTemplate::HornOfRecall), + 9 => Box::new(HornTemplate::HornOfChaos), + 10 => Box::new(HornTemplate::HornOfGlue), + 11 => Box::new(HornTemplate::HornOfValhalla), + 12 => Box::new(HornTemplate::HornOfTritons), + 13 => Box::new(HornTemplate::HornOfFog), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for HornTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Horn } fn flags1(&self) -> u64 { 0 } diff --git a/src/item_template/inn.rs b/src/item_template/inn.rs index 97e7d256..92c5cce9 100644 --- a/src/item_template/inn.rs +++ b/src/item_template/inn.rs @@ -22,18 +22,19 @@ impl LodgingAtInnTemplate { pub fn iter() -> impl Iterator> { LodgingAtInnTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for LodgingAtInnTemplate { - fn name(&self) -> &str { - match self { - LodgingAtInnTemplate::LodgingForOneDay => "Lodging for one day", - LodgingAtInnTemplate::LodgingForThreeDays => "Lodging for three days", - LodgingAtInnTemplate::LodgingForOneWeek => "Lodging for the week", - LodgingAtInnTemplate::RoomAndBoardForOneDay => "Room and board for one day", + pub fn from(subval: i64) -> Box { + match subval { + 300 => Box::new(LodgingAtInnTemplate::LodgingForOneDay), + 302 => Box::new(LodgingAtInnTemplate::LodgingForThreeDays), + 301 => Box::new(LodgingAtInnTemplate::LodgingForOneWeek), + 303 => Box::new(LodgingAtInnTemplate::RoomAndBoardForOneDay), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for LodgingAtInnTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::LodgingAtInn } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/instrument.rs b/src/item_template/instrument.rs index becc0916..015183e7 100644 --- a/src/item_template/instrument.rs +++ b/src/item_template/instrument.rs @@ -22,18 +22,19 @@ impl InstrumentTemplate { pub fn iter() -> impl Iterator> { InstrumentTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for InstrumentTemplate { - fn name(&self) -> &str { - match self { - InstrumentTemplate::PipesOfPeace => "& Pipes of Peace", - InstrumentTemplate::LyreOfNature => "& Lyre of Nature", - InstrumentTemplate::LuteOfTheWoods => "& Lute of the Woods", - InstrumentTemplate::HarpOfTheDruids =>"& Harp of the Druids" , + pub fn from(subval: i64) -> Box { + match subval { + 258 => Box::new(InstrumentTemplate::PipesOfPeace), + 259 => Box::new(InstrumentTemplate::LyreOfNature), + 260 => Box::new(InstrumentTemplate::LuteOfTheWoods), + 261 => Box::new(InstrumentTemplate::HarpOfTheDruids), + _ => panic!("subval {} out of bounds", subval), } } +} + +impl item_template::ItemTemplate for InstrumentTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Instrument } diff --git a/src/item_template/jewelry.rs b/src/item_template/jewelry.rs new file mode 100644 index 00000000..1aea6746 --- /dev/null +++ b/src/item_template/jewelry.rs @@ -0,0 +1,88 @@ +use model; +use item_template; + +#[derive(Copy, Clone, Eq, PartialEq, Hash)] +pub enum JewelryTemplate { + SmallGoldPendant, + SmallMithrilPendant, + LargeMithrilGarterBelt, + SmallSilverPendant, +} + +impl JewelryTemplate { + pub fn vec() -> Vec> { + vec![ + Box::new(JewelryTemplate::SmallGoldPendant), + Box::new(JewelryTemplate::SmallMithrilPendant), + Box::new(JewelryTemplate::LargeMithrilGarterBelt), + Box::new(JewelryTemplate::SmallSilverPendant), + ] + } + + pub fn iter() -> impl Iterator> { + JewelryTemplate::vec().into_iter() + } + + pub fn from(subval: i64) -> Box { + match subval { + 274 => Box::new(JewelryTemplate::SmallGoldPendant), + 275 => Box::new(JewelryTemplate::SmallMithrilPendant), + 276 => Box::new(JewelryTemplate::LargeMithrilGarterBelt), + 266 => Box::new(JewelryTemplate::SmallSilverPendant), + _ => panic!("subval {} out of bounds", subval), + } + } +} + +impl item_template::ItemTemplate for JewelryTemplate { + fn item_type(&self) -> model::ItemType { + match self { + JewelryTemplate::SmallGoldPendant => model::ItemType::Jewelry, + JewelryTemplate::SmallMithrilPendant => model::ItemType::Jewelry, + JewelryTemplate::LargeMithrilGarterBelt => model::ItemType::Jewelry, + JewelryTemplate::SmallSilverPendant => model::ItemType::Jewelry, + } + } + + fn flags1(&self) -> u64 { 0 } + fn flags2(&self) -> u64 { 0 } + fn p1(&self) -> i64 { 0 } + + fn cost(&self) -> i64 { + match self { + JewelryTemplate::SmallGoldPendant => 75, + JewelryTemplate::SmallMithrilPendant => 350, + JewelryTemplate::LargeMithrilGarterBelt => 1500, + JewelryTemplate::SmallSilverPendant => 60, + } + } + + fn subtype(&self) -> i64 { + match self { + JewelryTemplate::SmallGoldPendant => 274, + JewelryTemplate::SmallMithrilPendant => 275, + JewelryTemplate::LargeMithrilGarterBelt => 276, + JewelryTemplate::SmallSilverPendant => 266, + } + } + + fn weight(&self) -> u16 { 5 } + fn number(&self) -> u16 { 1 } + fn modifier_to_hit(&self) -> i16 { 0 } + fn modifier_to_damage(&self) -> i16 { 0 } + fn base_ac(&self) -> i16 { 0 } + fn modifier_to_ac(&self) -> i16 { 0 } + fn damage(&self) -> &str { "1d1" } + + fn item_level(&self) -> u8 { + match self { + JewelryTemplate::SmallGoldPendant => 5, + JewelryTemplate::SmallMithrilPendant => 10, + JewelryTemplate::LargeMithrilGarterBelt => 45, + JewelryTemplate::SmallSilverPendant => 5, + } + } + + fn is_identified(&self) -> bool { false } +} + diff --git a/src/item_template/junk_food.rs b/src/item_template/junk_food.rs index 0326877e..e7f39311 100644 --- a/src/item_template/junk_food.rs +++ b/src/item_template/junk_food.rs @@ -40,27 +40,28 @@ impl JunkFoodTemplate { pub fn iter() -> impl Iterator> { JunkFoodTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for JunkFoodTemplate { - fn name(&self) -> &str { - match self { - JunkFoodTemplate::BoxOfPiranhaCrackers => "& Box~ of Piranha Crackers", - JunkFoodTemplate::CanOfOrcaCola => "& Can~ of Orca-Cola", - JunkFoodTemplate::TwelvePoundTrollBuger => "& Twelve-Pound Troll Burger~", - JunkFoodTemplate::BagOfBrontosaurusChips => "& Bag~ of Brontosaurus Chips", - JunkFoodTemplate::SliceOfPurpleMushroomPizza => "& Slice~ of Purple Mushroom Pizza", - JunkFoodTemplate::PeanutButterAndGrapeJellySandwich => "& Peanut Butter and Grape Jelly Sandwich~", - JunkFoodTemplate::DragonSteak => "& Dragon Steak~", - JunkFoodTemplate::VorpalBunnyThroatLozenge => "& Vorpal Bunny Throat Lozenge~", - JunkFoodTemplate::DeepFriedGiantCentipede => "& Deep-Fried Giant Centipede~", - JunkFoodTemplate::PintOfBeetleJuice => "& Pint~ of Beetle Juice", - JunkFoodTemplate::BownOfBatStew => "& Bowl~ of Bat Stew", - JunkFoodTemplate::JarOfPickledLeeches => "& Jar~ of Pickled Leeches", - JunkFoodTemplate::PackOfKittenMcNuggets => "& Pack~ of Kitten McNuggets", + pub fn from(subval: i64) -> Box { + match subval { + 257 => Box::new(JunkFoodTemplate::BoxOfPiranhaCrackers), + 258 => Box::new(JunkFoodTemplate::CanOfOrcaCola), + 259 => Box::new(JunkFoodTemplate::TwelvePoundTrollBuger), + 260 => Box::new(JunkFoodTemplate::BagOfBrontosaurusChips), + 261 => Box::new(JunkFoodTemplate::SliceOfPurpleMushroomPizza), + 262 => Box::new(JunkFoodTemplate::PeanutButterAndGrapeJellySandwich), + 263 => Box::new(JunkFoodTemplate::DragonSteak), + 264 => Box::new(JunkFoodTemplate::VorpalBunnyThroatLozenge), + 265 => Box::new(JunkFoodTemplate::DeepFriedGiantCentipede), + 266 => Box::new(JunkFoodTemplate::PintOfBeetleJuice), + 267 => Box::new(JunkFoodTemplate::BownOfBatStew), + 268 => Box::new(JunkFoodTemplate::JarOfPickledLeeches), + 269 => Box::new(JunkFoodTemplate::PackOfKittenMcNuggets), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for JunkFoodTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::JunkFood } fn flags1(&self) -> u64 { diff --git a/src/item_template/light_source.rs b/src/item_template/light_source.rs index 714fc82f..c1b24cee 100644 --- a/src/item_template/light_source.rs +++ b/src/item_template/light_source.rs @@ -22,18 +22,19 @@ impl LightSourceTemplate { pub fn iter() -> impl Iterator> { LightSourceTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for LightSourceTemplate { - fn name(&self) -> &str { - match self { - LightSourceTemplate::WoodenTorch => "& Wooden Torch~ with %P5 turns of light", - LightSourceTemplate::BrassLantern => "& Brass Lantern~ with %P5 turns of light", - LightSourceTemplate::MagicTorch => "& Magic Torch^ with %P5 turns of light", - LightSourceTemplate::MagicLantern => "& Magic Lantern^ with %P5 turns of light", + pub fn from(subval: i64) -> Box { + match subval { + 13 => Box::new(LightSourceTemplate::WoodenTorch), + 1 => Box::new(LightSourceTemplate::BrassLantern), + 30 => Box::new(LightSourceTemplate::MagicTorch), + 17 => Box::new(LightSourceTemplate::MagicLantern), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for LightSourceTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::LightSource } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/mace.rs b/src/item_template/mace.rs index 4c3b9ed2..c0f1c822 100644 --- a/src/item_template/mace.rs +++ b/src/item_template/mace.rs @@ -35,26 +35,26 @@ impl MaceTemplate { pub fn iter() -> impl Iterator> { MaceTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for MaceTemplate { - fn name(&self) -> &str { - match self { - MaceTemplate::BallAndChain => "Ball and Chain (%P0)^ (%P2,%P3)", - MaceTemplate::WoodenClub => "Wooden Club (%P0)^ (%P2,%P3)", - MaceTemplate::Flail => "Flail (%P0)^ (%P2,%P3)", - MaceTemplate::GreatFlail => "Two Handed Great Flail (%P0)^ (%P2,%P3)", - MaceTemplate::MorningStar => "Morningstar (%P0)^ (%P2,%P3)", - MaceTemplate::Mace => "Mace (%P0)^ (%P2,%P3)", - MaceTemplate::WarHammer => "War Hammer (%P0)^ (%P2,%P3)", - MaceTemplate::LeadFilledMace => "Lead Filled Mace (%P0)^ (%P2,%P3)", - MaceTemplate::IronShodQuarterstaff => "Iron Shod Quarterstaff (%P0)^ (%P2,%P3)", - MaceTemplate::OgreMaul => "Ogre Maul (%P0)^ (%P2,%P3)", + pub fn from(subval: i64) -> Box { + match subval { + 2 => Box::new(MaceTemplate::BallAndChain), + 6 => Box::new(MaceTemplate::WoodenClub), + 7 => Box::new(MaceTemplate::Flail), + 8 => Box::new(MaceTemplate::GreatFlail), + 9 => Box::new(MaceTemplate::MorningStar), + 10 => Box::new(MaceTemplate::Mace), + 11 => Box::new(MaceTemplate::WarHammer), + 12 => Box::new(MaceTemplate::LeadFilledMace), + 13 => Box::new(MaceTemplate::IronShodQuarterstaff), + 14 => Box::new(MaceTemplate::OgreMaul), + _ => panic!("subval {} out of bounds", subval), } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::Maul } +impl item_template::ItemTemplate for MaceTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Mace } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } fn p1(&self) -> i64 { 0 } diff --git a/src/item_template/magic_book.rs b/src/item_template/magic_book.rs index 51a690f8..b0385b0e 100644 --- a/src/item_template/magic_book.rs +++ b/src/item_template/magic_book.rs @@ -22,18 +22,19 @@ impl MagicBookTemplate { pub fn iter() -> impl Iterator> { MagicBookTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for MagicBookTemplate { - fn name(&self) -> &str { - match self { - MagicBookTemplate::BeginnersMagic => "& Book of Magic Spells [Beginners-Magik]", - MagicBookTemplate::Magic1 => "& Book of Magic Spells [Magik I]", - MagicBookTemplate::Magic2 => "& Book of Magic Spells [Magik II]", - MagicBookTemplate::MagesGuideToPower => "& Book of Magic Spells [The Mages Guide to Power]", + pub fn from(subval: i64) -> Box { + match subval { + 257 => Box::new(MagicBookTemplate::BeginnersMagic), + 258 => Box::new(MagicBookTemplate::Magic1), + 259 => Box::new(MagicBookTemplate::Magic2), + 261 => Box::new(MagicBookTemplate::MagesGuideToPower), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for MagicBookTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::MagicBook } fn flags1(&self) -> u64 { diff --git a/src/item_template/misc.rs b/src/item_template/misc.rs index 371af0ca..f137ef44 100644 --- a/src/item_template/misc.rs +++ b/src/item_template/misc.rs @@ -36,26 +36,27 @@ impl MiscTemplate { pub fn iter() -> impl Iterator> { MiscTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for MiscTemplate { - fn name(&self) -> &str { - match self { - MiscTemplate::RatSkeleton => "& Rat Skeleton", - MiscTemplate::GiantCentipedeSkeleton => "& Giant Centipede Skeleton", - MiscTemplate::EmptyBottle => "& Empty Bottle^", - MiscTemplate::PotteryShard => "Some Shards of Pottery^", - MiscTemplate::HumanSkeleton => "& Human Skeleton", - MiscTemplate::DwarfSkeleton => "& Dwarf Skeleton", - MiscTemplate::ElfSkeleton => "& Elf Skeleton", - MiscTemplate::GnomeSkeleton => "& Gnome Skeleton", - MiscTemplate::BrokenTeeth => "& Broken Set of Teeth^", - MiscTemplate::LargeBrokenBone => "& Large Broken Bone^", - MiscTemplate::BrokenStick => "& Broken Stick^", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(MiscTemplate::RatSkeleton), + 2 => Box::new(MiscTemplate::GiantCentipedeSkeleton), + 4 => Box::new(MiscTemplate::EmptyBottle), + 5 => Box::new(MiscTemplate::PotteryShard), + 7 => Box::new(MiscTemplate::HumanSkeleton), + 8 => Box::new(MiscTemplate::DwarfSkeleton), + 9 => Box::new(MiscTemplate::ElfSkeleton), + 10 => Box::new(MiscTemplate::GnomeSkeleton), + 11 => Box::new(MiscTemplate::BrokenTeeth), + 12 => Box::new(MiscTemplate::LargeBrokenBone), + 13 => Box::new(MiscTemplate::BrokenStick), + _ => panic!("subval {} out of bounds", subval), } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::MiscUsable } +impl item_template::ItemTemplate for MiscTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::MiscObject } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } fn p1(&self) -> i64 { 0 } diff --git a/src/item_template/misc_usable.rs b/src/item_template/misc_usable.rs index 03bc962d..97bb148e 100644 --- a/src/item_template/misc_usable.rs +++ b/src/item_template/misc_usable.rs @@ -6,6 +6,7 @@ pub enum MiscUsableTemplate { FlaskOfOil, IronSpike, Statue, + Teeth, SilverCross, GoldCross, MithrilCross, @@ -19,6 +20,7 @@ impl MiscUsableTemplate { Box::new(MiscUsableTemplate::FlaskOfOil), Box::new(MiscUsableTemplate::IronSpike), Box::new(MiscUsableTemplate::Statue), + Box::new(MiscUsableTemplate::Teeth), Box::new(MiscUsableTemplate::SilverCross), Box::new(MiscUsableTemplate::GoldCross), Box::new(MiscUsableTemplate::MithrilCross), @@ -30,27 +32,30 @@ impl MiscUsableTemplate { pub fn iter() -> impl Iterator> { MiscUsableTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for MiscUsableTemplate { - fn name(&self) -> &str { - match self { - MiscUsableTemplate::FlaskOfOil => "& Flask~ of Oil", - MiscUsableTemplate::IronSpike => "& Iron Spike~", - MiscUsableTemplate::Statue => "& %A Statue^", - MiscUsableTemplate::SilverCross => "& Silver Cross^", - MiscUsableTemplate::GoldCross => "& Gold Cross^", - MiscUsableTemplate::MithrilCross => "& Mithril Cross^", - MiscUsableTemplate::Cross => "& %M Cross^", - MiscUsableTemplate::CorkedBottle => "& Corked Bottle^", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(MiscUsableTemplate::IronSpike), + 14 => Box::new(MiscUsableTemplate::Statue), + 15 => Box::new(MiscUsableTemplate::Teeth), + 16 => Box::new(MiscUsableTemplate::SilverCross), + 17 => Box::new(MiscUsableTemplate::GoldCross), + 18 => Box::new(MiscUsableTemplate::MithrilCross), + 19 => Box::new(MiscUsableTemplate::Cross), + 21 => Box::new(MiscUsableTemplate::CorkedBottle), + 257 => Box::new(MiscUsableTemplate::FlaskOfOil), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for MiscUsableTemplate { fn item_type(&self) -> model::ItemType { match self { MiscUsableTemplate::FlaskOfOil => model::ItemType::FlaskOfOil, MiscUsableTemplate::IronSpike => model::ItemType::Spike, MiscUsableTemplate::Statue => model::ItemType::MiscUsable, + MiscUsableTemplate::Teeth => model::ItemType::MiscUsable, MiscUsableTemplate::SilverCross => model::ItemType::MiscUsable, MiscUsableTemplate::GoldCross => model::ItemType::MiscUsable, MiscUsableTemplate::MithrilCross => model::ItemType::MiscUsable, @@ -67,6 +72,7 @@ impl item_template::ItemTemplate for MiscUsableTemplate { MiscUsableTemplate::FlaskOfOil => 0x00040000, MiscUsableTemplate::IronSpike => 0, MiscUsableTemplate::Statue => 0, + MiscUsableTemplate::Teeth => 0, MiscUsableTemplate::SilverCross => 0, MiscUsableTemplate::GoldCross => 0, MiscUsableTemplate::MithrilCross => 0, @@ -80,6 +86,7 @@ impl item_template::ItemTemplate for MiscUsableTemplate { MiscUsableTemplate::FlaskOfOil => 7500, MiscUsableTemplate::IronSpike => 0, MiscUsableTemplate::Statue => 0, + MiscUsableTemplate::Teeth => 0, MiscUsableTemplate::SilverCross => 0, MiscUsableTemplate::GoldCross => 0, MiscUsableTemplate::MithrilCross => 0, @@ -93,6 +100,7 @@ impl item_template::ItemTemplate for MiscUsableTemplate { MiscUsableTemplate::FlaskOfOil => 3, MiscUsableTemplate::IronSpike => 1, MiscUsableTemplate::Statue => 20, + MiscUsableTemplate::Teeth => 0, MiscUsableTemplate::SilverCross => 250, MiscUsableTemplate::GoldCross => 500, MiscUsableTemplate::MithrilCross => 750, @@ -106,6 +114,7 @@ impl item_template::ItemTemplate for MiscUsableTemplate { MiscUsableTemplate::FlaskOfOil => 257, MiscUsableTemplate::IronSpike => 1, MiscUsableTemplate::Statue => 14, + MiscUsableTemplate::Teeth => 15, MiscUsableTemplate::SilverCross => 16, MiscUsableTemplate::GoldCross => 17, MiscUsableTemplate::MithrilCross => 18, @@ -119,6 +128,7 @@ impl item_template::ItemTemplate for MiscUsableTemplate { MiscUsableTemplate::FlaskOfOil => 10, MiscUsableTemplate::IronSpike => 10, MiscUsableTemplate::Statue => 10, + MiscUsableTemplate::Teeth => 1, MiscUsableTemplate::SilverCross => 3, MiscUsableTemplate::GoldCross => 5, MiscUsableTemplate::MithrilCross => 10, @@ -138,6 +148,7 @@ impl item_template::ItemTemplate for MiscUsableTemplate { MiscUsableTemplate::FlaskOfOil => "2d6", MiscUsableTemplate::IronSpike => "1d1", MiscUsableTemplate::Statue => "1d2", + MiscUsableTemplate::Teeth => "1d1", MiscUsableTemplate::SilverCross => "1d1", MiscUsableTemplate::GoldCross => "1d1", MiscUsableTemplate::MithrilCross => "1d1", @@ -151,6 +162,7 @@ impl item_template::ItemTemplate for MiscUsableTemplate { MiscUsableTemplate::FlaskOfOil => 10, MiscUsableTemplate::IronSpike => 20, MiscUsableTemplate::Statue => 1, + MiscUsableTemplate::Teeth => 1, MiscUsableTemplate::SilverCross => 25, MiscUsableTemplate::GoldCross => 1, MiscUsableTemplate::MithrilCross => 45, diff --git a/src/item_template/mod.rs b/src/item_template/mod.rs index 3d1b03fb..f1286a92 100644 --- a/src/item_template/mod.rs +++ b/src/item_template/mod.rs @@ -1,7 +1,8 @@ pub use self::template::ItemTemplate; pub use self::ammunition::AmmunitionTemplate; pub use self::amulet::AmuletTemplate; -pub use self::armor::ArmorTemplate; +pub use self::armor_hard::HardArmorTemplate; +pub use self::armor_soft::SoftArmorTemplate; pub use self::axe::AxeTemplate; pub use self::bag::BagTemplate; pub use self::belt::BeltTemplate; @@ -13,12 +14,15 @@ pub use self::chime::ChimeTemplate; pub use self::cloak::CloakTemplate; pub use self::crossbow::CrossbowTemplate; pub use self::dagger::DaggerTemplate; +pub use self::dungeon_feature::DungeonFeatureTemplate; pub use self::food::FoodTemplate; +pub use self::gem::GemTemplate; pub use self::gloves::GlovesTemplate; pub use self::helm::HelmTemplate; pub use self::horn::HornTemplate; pub use self::instrument::InstrumentTemplate; pub use self::inn::LodgingAtInnTemplate; +pub use self::jewelry::JewelryTemplate; pub use self::junk_food::JunkFoodTemplate; pub use self::light_source::LightSourceTemplate; pub use self::mace::MaceTemplate; @@ -36,12 +40,13 @@ pub use self::sling::SlingTemplate; pub use self::song_book::SongBookTemplate; pub use self::staff::StaffTemplate; pub use self::sword::SwordTemplate; -pub use self::valuable::ValuableTemplate; pub use self::wand::WandTemplate; +pub use self::wearable_gem::WearableGemTemplate; mod ammunition; mod amulet; -mod armor; +mod armor_hard; +mod armor_soft; mod axe; mod bag; mod belt; @@ -53,12 +58,15 @@ mod chime; mod cloak; mod crossbow; mod dagger; +mod dungeon_feature; mod food; +mod gem; mod gloves; mod helm; mod horn; mod inn; mod instrument; +mod jewelry; mod junk_food; mod light_source; mod mace; @@ -77,5 +85,5 @@ mod song_book; mod staff; mod sword; mod template; -mod valuable; mod wand; +mod wearable_gem; diff --git a/src/item_template/pick.rs b/src/item_template/pick.rs index 557f4559..4a552c12 100644 --- a/src/item_template/pick.rs +++ b/src/item_template/pick.rs @@ -28,22 +28,22 @@ impl PickTemplate { pub fn iter() -> impl Iterator> { PickTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for PickTemplate { - fn name(&self) -> &str { - match self { - PickTemplate::Pick => "& Pick (%P1) (%P2,%P3)", - PickTemplate::Shovel => "& Shovel (%P1) (%P2,%P3)", - PickTemplate::OrcishPick1 => "& Orcish Pick^ (%P1) (%P2,%P3)", - PickTemplate::OrcishPick2 => "& Orcish Pick^ (%P1) (%P2,%P3)", - PickTemplate::DwarvenPick => "& Dwarven Pick^ (%P1) (%P2,%P3)", - PickTemplate::GnomishShovel => "& Gnomish Shovel^ (%P1) (%P2,%P3)", - PickTemplate::DwarvenShovel => "& Dwarven Shovel^ (%P1) (%P2,%P3)", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(PickTemplate::Pick), + 2 => Box::new(PickTemplate::Shovel), + 4 => Box::new(PickTemplate::OrcishPick1), + 7 => Box::new(PickTemplate::OrcishPick2), + 3 => Box::new(PickTemplate::DwarvenPick), + 5 => Box::new(PickTemplate::GnomishShovel), + 6 => Box::new(PickTemplate::DwarvenShovel), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for PickTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Pick } fn flags1(&self) -> u64 { @@ -98,7 +98,7 @@ impl item_template::ItemTemplate for PickTemplate { match self { PickTemplate::Pick => 1, PickTemplate::Shovel => 2, - PickTemplate::OrcishPick1 => 2, + PickTemplate::OrcishPick1 => 4, PickTemplate::OrcishPick2 => 7, PickTemplate::DwarvenPick => 3, PickTemplate::GnomishShovel => 5, diff --git a/src/item_template/polearm.rs b/src/item_template/polearm.rs index d6221cc1..4408dff5 100644 --- a/src/item_template/polearm.rs +++ b/src/item_template/polearm.rs @@ -39,28 +39,28 @@ impl PolearmTemplate { pub fn iter() -> impl Iterator> { PolearmTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for PolearmTemplate { - fn name(&self) -> &str { - match self { - PolearmTemplate::AwlPike => "Awl-Pike (%P0)^ (%P2,%P3)", - PolearmTemplate::BeakedAxe => "Beaked Axe (%P0)^ (%P2,%P3)", - PolearmTemplate::Fauchard => "Fauchard (%P0)^ (%P2,%P3)", - PolearmTemplate::Glaive => "Glaive (%P0)^ (%P2,%P3)", - PolearmTemplate::Halberd => "Halberd (%P0)^ (%P2,%P3)", - PolearmTemplate::LucerneHammer => "Lucerne Hammer (%P0)^ (%P2,%P3)", - PolearmTemplate::Pike => "Pike (%P0)^ (%P2,%P3)", - PolearmTemplate::Spike => "Spear (%P0)^ (%P2,%P3)", - PolearmTemplate::Lance => "Lance (%P0)^ (%P2,%P3)", - PolearmTemplate::Javelin => "Javelin (%P0)^ (%P2,%P3)", - PolearmTemplate::Naginata => "Naginata (%P0)^ (%P2,%P3)", - PolearmTemplate::WarScythe => "War Scythe (%P0)^ (%P2,%P3)", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(PolearmTemplate::AwlPike), + 2 => Box::new(PolearmTemplate::BeakedAxe), + 3 => Box::new(PolearmTemplate::Fauchard), + 4 => Box::new(PolearmTemplate::Glaive), + 5 => Box::new(PolearmTemplate::Halberd), + 6 => Box::new(PolearmTemplate::LucerneHammer), + 7 => Box::new(PolearmTemplate::Pike), + 8 => Box::new(PolearmTemplate::Spike), + 9 => Box::new(PolearmTemplate::Lance), + 10 => Box::new(PolearmTemplate::Javelin), + 11 => Box::new(PolearmTemplate::Naginata), + 12 => Box::new(PolearmTemplate::WarScythe), + _ => panic!("subval {} out of bounds", subval), } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::PoleArm } +impl item_template::ItemTemplate for PolearmTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Polearm } fn flags1(&self) -> u64 { 0x10000000 } fn flags2(&self) -> u64 { 0 } fn p1(&self) -> i64 { 0 } diff --git a/src/item_template/potion.rs b/src/item_template/potion.rs index 11f7f32e..12354520 100644 --- a/src/item_template/potion.rs +++ b/src/item_template/potion.rs @@ -104,60 +104,61 @@ impl PotionTemplate { pub fn iter() -> impl Iterator> { PotionTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for PotionTemplate { - fn name(&self) -> &str { - match self { - PotionTemplate::AppleJuice => "& Potion~| of Apple Juice", - PotionTemplate::Blindness => "& Potion~| of Blindness", - PotionTemplate::Boldliness => "& Potion~| of Boldliness", - PotionTemplate::Charisma => "& Potion~| of Charisma", - PotionTemplate::Confusion => "& Potion~| of Confusion", - PotionTemplate::CureCriticalWounds => "& Potion~| of Cure Critical Wounds", - PotionTemplate::CureLightWounds => "& Potion~| of Cure Light Wounds", - PotionTemplate::CureSeriousWounds => "& Potion~| of Cure Serious Wounds", - PotionTemplate::DetectInvisible => "& Potion~| of Detect Invisible", - PotionTemplate::FleaBile => "& Potion~| of Flea Bile", - PotionTemplate::GainConstitution => "& Potion~| of Gain Constitution", - PotionTemplate::GainDexterity => "& Potion~| of Gain Dexterity", - PotionTemplate::GainExperience => "& Potion~| of Gain Experience", - PotionTemplate::GainIntelligence => "& Potion~| of Restore Strength", - PotionTemplate::GainStrength => "& Potion~| of Gain Strength", - PotionTemplate::GainWisdom => "& Potion~| of Gain Wisdom", - PotionTemplate::HasteSelf => "& Potion~| of Haste Self", - PotionTemplate::Healing => "& Potion~| of Healing", - PotionTemplate::Heroism => "& Potion~| of Heroism", - PotionTemplate::InfraVision => "& Potion~| of Infra-Vision", - PotionTemplate::Invulnerability => "& Potion~| of Invulnerability", - PotionTemplate::Learning => "& Potion~| of Learning", - PotionTemplate::LoseIntelligence => "& Potion~| of Lose Intelligence", - PotionTemplate::LoseMemories => "& Potion~| of Lose Memories", - PotionTemplate::LoseWisdom => "& Potion~| of Lose Wisdom", - PotionTemplate::NeutralizePoison => "& Potion~| of Neutralize Poison", - PotionTemplate::Poison => "& Potion~| of Poison", - PotionTemplate::ResistCold => "& Potion~| of Resist Cold", - PotionTemplate::ResistHeat => "& Potion~| of Resist Heat", - PotionTemplate::RestoreCharisma => "& Potion~| of Restore Charisma", - PotionTemplate::RestoreConstitution => "& Potion~| of Restore Consitution", - PotionTemplate::RestoreDexterity => "& Potion~| of Restore Dexterity", - PotionTemplate::RestoreIntelligence => "& Potion~| of Restore Intelligence", - PotionTemplate::RestoreLifeLevels => "& Potion~| of Restore Life Levels", - PotionTemplate::RestoreMana => "& Potion~| of Restore Mana", - PotionTemplate::RestoreStrength => "& Potion~| of Restore Strength", - PotionTemplate::RestoreWisdom => "& Potion~| of Restore Wisdom", - PotionTemplate::SaltWater => "& Potion~| of Salt Water", - PotionTemplate::Sleep => "& Potion~| of Sleep", - PotionTemplate::SlimeMoldJuice => "& Potion~| of Slime Mold Juice", - PotionTemplate::SlowPoison => "& Potion~| of Slow Poison", - PotionTemplate::Slowness => "& Potion~| of Slowness", - PotionTemplate::SuperHeroism => "& Potion~| of Super Heroism", - PotionTemplate::Ugliness => "& Potion~| of Ugliness", - PotionTemplate::Water => "& Potion~| of Water", + pub fn from(subval: i64) -> Box { + match subval { + 276 => Box::new(PotionTemplate::Blindness), + 293 => Box::new(PotionTemplate::Boldliness), + 266 => Box::new(PotionTemplate::Charisma), + 277 => Box::new(PotionTemplate::Confusion), + 271 => Box::new(PotionTemplate::CureCriticalWounds), + 269 => Box::new(PotionTemplate::CureLightWounds), + 270 => Box::new(PotionTemplate::CureSeriousWounds), + 297 => Box::new(PotionTemplate::DetectInvisible), + 302 => Box::new(PotionTemplate::FleaBile), + 273 => Box::new(PotionTemplate::GainConstitution), + 284 => Box::new(PotionTemplate::GainDexterity), + 274 => Box::new(PotionTemplate::GainExperience), + 260 => Box::new(PotionTemplate::GainIntelligence), + 257 => Box::new(PotionTemplate::GainStrength), + 263 => Box::new(PotionTemplate::GainWisdom), + 279 => Box::new(PotionTemplate::HasteSelf), + 272 => Box::new(PotionTemplate::Healing), + 291 => Box::new(PotionTemplate::Heroism), + 301 => Box::new(PotionTemplate::InfraVision), + 290 => Box::new(PotionTemplate::Invulnerability), + 287 => Box::new(PotionTemplate::Learning), + 261 => Box::new(PotionTemplate::LoseIntelligence), + 288 => Box::new(PotionTemplate::LoseMemories), + 264 => Box::new(PotionTemplate::LoseWisdom), + 299 => Box::new(PotionTemplate::NeutralizePoison), + 258 => Box::new(PotionTemplate::Poison), + 296 => Box::new(PotionTemplate::ResistCold), + 295 => Box::new(PotionTemplate::ResistHeat), + 268 => Box::new(PotionTemplate::RestoreCharisma), + 286 => Box::new(PotionTemplate::RestoreConstitution), + 285 => Box::new(PotionTemplate::RestoreDexterity), + 262 => Box::new(PotionTemplate::RestoreIntelligence), + 294 => Box::new(PotionTemplate::RestoreLifeLevels), + 300 => Box::new(PotionTemplate::RestoreMana), + 259 => Box::new(PotionTemplate::RestoreStrength), + 265 => Box::new(PotionTemplate::RestoreWisdom), + 289 => Box::new(PotionTemplate::SaltWater), + 275 => Box::new(PotionTemplate::Sleep), + 298 => Box::new(PotionTemplate::SlowPoison), + 280 => Box::new(PotionTemplate::Slowness), + 292 => Box::new(PotionTemplate::SuperHeroism), + 267 => Box::new(PotionTemplate::Ugliness), + 283 => Box::new(PotionTemplate::Water), + 281 => Box::new(PotionTemplate::SlimeMoldJuice), + 282 => Box::new(PotionTemplate::AppleJuice), + _ => panic!("subval {} out of bounds", subval), } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::Potion1 } +impl item_template::ItemTemplate for PotionTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Potion } fn flags1(&self) -> u64 { match self { diff --git a/src/item_template/prayer_book.rs b/src/item_template/prayer_book.rs index ee7db193..f445ff8b 100644 --- a/src/item_template/prayer_book.rs +++ b/src/item_template/prayer_book.rs @@ -22,18 +22,19 @@ impl PrayerBookTemplate { pub fn iter() -> impl Iterator> { PrayerBookTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for PrayerBookTemplate { - fn name(&self) -> &str { - match self { - PrayerBookTemplate::BeginnersHandbook => "& Holy Book of Prayers [Beginners Handbook]", - PrayerBookTemplate::WordsOfWisdom => "& Holy Book of Prayers [Words of Wisdom]", - PrayerBookTemplate::ChantsAndBlessings => "& Holy Book of Prayers [Chants and Blessings]", - PrayerBookTemplate::ExorcismAndDispelling => "& Holy Book of Prayers [Exorcism and Dispelling]", + pub fn from(subval: i64) -> Box { + match subval { + 258 => Box::new(PrayerBookTemplate::BeginnersHandbook), + 259 => Box::new(PrayerBookTemplate::WordsOfWisdom), + 260 => Box::new(PrayerBookTemplate::ChantsAndBlessings), + 261 => Box::new(PrayerBookTemplate::ExorcismAndDispelling), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for PrayerBookTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::PrayerBook } fn flags1(&self) -> u64 { diff --git a/src/item_template/ring.rs b/src/item_template/ring.rs index 3b2dae39..7466db8a 100644 --- a/src/item_template/ring.rs +++ b/src/item_template/ring.rs @@ -80,47 +80,48 @@ impl RingTemplate { pub fn iter() -> impl Iterator> { RingTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for RingTemplate { - fn name(&self) -> &str { - match self { - RingTemplate::RingOfGainStrength => "& Ring| of Gain Strength^ (%p1)", - RingTemplate::RingOfGainDexterity => "& Ring| of Gain Dexterity^ (%p1)", - RingTemplate::RingOfGainConstitution => "& Ring| of Gain Constitution^ (%p1)", - RingTemplate::RingOfGainIntelligence => "& Ring| of Gain Intelligence^ (%p1)", - RingTemplate::RingOfSpeed1 => "& Ring| of Speed^ (%p1)", - RingTemplate::RingOfSpeed2 => "& Ring| of Speed^ (%p1)", - RingTemplate::RingOfSearching => "& Ring| of Searching^ (%p1)", - RingTemplate::RingOfTeleportation => "& Ring| of Teleportation^", - RingTemplate::RingOfSlowDigestion => "& Ring| of Slow Digestion^", - RingTemplate::RingOfResistFire => "& Ring| of Resist Fire^", - RingTemplate::RingOfResistCold => "& Ring| of Resist Cold^", - RingTemplate::RingOfFeatherFalling => "& Ring| of Feather Falling^", - RingTemplate::RingOfAdornment1 => "& Ring| of Adornment^", - RingTemplate::RingOfAdornment2 => "& Ring| of Adornment^", - RingTemplate::RingOfWeakness => "& Ring| of Weakness^", - RingTemplate::RingOfLordlyProtectionFire => "& Ring| of Lordly Protection (Fire)^", - RingTemplate::RingOfLordlyProtectionAcid => "& Ring| of Lordly Protection (Acid)^", - RingTemplate::RingOfLordlyProtectionCold => "& Ring| of Lordly Protection (Cold)^", - RingTemplate::RingOfWoe => "& Ring| of Woe^", - RingTemplate::RingOfStupidity => "& Ring| of Stupidity^", - RingTemplate::RingOfIncreaseDamage => "& Ring| of Increase Damage^ (%p3)", - RingTemplate::RingOfIncreaseToHit => "& Ring| of Increase To-hit^ (%p2)", - RingTemplate::RingOfProtection => "& Ring| of Protection^ [%p4]", - RingTemplate::RingOfAggravateMonsters => "& Ring| of Aggravate Monster^", - RingTemplate::RingOfSeeInvisible => "& Ring| of See Invisible^", - RingTemplate::RingOfSustainStrength => "& Ring| of Sustain Strength^", - RingTemplate::RingOfSustainIntelligence => "& Ring| of Sustain Intelligence^", - RingTemplate::RingOfSustainWisdom => "& Ring| of Sustain Wisdom^", - RingTemplate::RingOfSustainConstitution => "& Ring| of Sustain Constitution^", - RingTemplate::RingOfSustainDexterity => "& Ring| of Sustain Dexterity^", - RingTemplate::RingOfSustainCharisma => "& Ring| of Sustain Charisma^", - RingTemplate::RingOfSlaying => "& Ring| of Slaying^", - RingTemplate::RingOfGnomekind => "& Ring| of Gnomekind^", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(RingTemplate::RingOfGainStrength), + 2 => Box::new(RingTemplate::RingOfGainDexterity), + 3 => Box::new(RingTemplate::RingOfGainConstitution), + 4 => Box::new(RingTemplate::RingOfGainIntelligence), + 7 => Box::new(RingTemplate::RingOfSpeed1), + 35 => Box::new(RingTemplate::RingOfSpeed2), + 8 => Box::new(RingTemplate::RingOfSearching), + 9 => Box::new(RingTemplate::RingOfTeleportation), + 10 => Box::new(RingTemplate::RingOfSlowDigestion), + 11 => Box::new(RingTemplate::RingOfResistFire), + 12 => Box::new(RingTemplate::RingOfResistCold), + 13 => Box::new(RingTemplate::RingOfFeatherFalling), + 14 => Box::new(RingTemplate::RingOfAdornment1), + 15 => Box::new(RingTemplate::RingOfAdornment2), + 16 => Box::new(RingTemplate::RingOfWeakness), + 17 => Box::new(RingTemplate::RingOfLordlyProtectionFire), + 18 => Box::new(RingTemplate::RingOfLordlyProtectionAcid), + 19 => Box::new(RingTemplate::RingOfLordlyProtectionCold), + 20 => Box::new(RingTemplate::RingOfWoe), + 21 => Box::new(RingTemplate::RingOfStupidity), + 22 => Box::new(RingTemplate::RingOfIncreaseDamage), + 23 => Box::new(RingTemplate::RingOfIncreaseToHit), + 24 => Box::new(RingTemplate::RingOfProtection), + 25 => Box::new(RingTemplate::RingOfAggravateMonsters), + 26 => Box::new(RingTemplate::RingOfSeeInvisible), + 27 => Box::new(RingTemplate::RingOfSustainStrength), + 28 => Box::new(RingTemplate::RingOfSustainIntelligence), + 29 => Box::new(RingTemplate::RingOfSustainWisdom), + 30 => Box::new(RingTemplate::RingOfSustainConstitution), + 31 => Box::new(RingTemplate::RingOfSustainDexterity), + 32 => Box::new(RingTemplate::RingOfSustainCharisma), + 33 => Box::new(RingTemplate::RingOfSlaying), + 34 => Box::new(RingTemplate::RingOfGnomekind), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for RingTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Ring } fn flags1(&self) -> u64 { 0 } diff --git a/src/item_template/scroll.rs b/src/item_template/scroll.rs index 1e25a13b..a4418c16 100644 --- a/src/item_template/scroll.rs +++ b/src/item_template/scroll.rs @@ -98,58 +98,58 @@ impl ScrollTemplate { pub fn iter() -> impl Iterator> { ScrollTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for ScrollTemplate { - fn name(&self) -> &str { - match self { - ScrollTemplate::AggravateMonster => "& Scroll~| of Trap/Door Destruction", - ScrollTemplate::Blessing => "& Scroll~| of Blessing", - ScrollTemplate::CreateFood => "& Scroll~| of Create Food", - ScrollTemplate::CurseArmor => "& Scroll~| of Curse Armor", - ScrollTemplate::CurseWeapon => "& Scroll~| of Curse Weapon", - ScrollTemplate::Darkness => "& Scroll~| of Darkness", - ScrollTemplate::Destruction => "& Scroll~| of Destruction", - ScrollTemplate::DetectInvisible => "& Scroll~| of Detect Invisible", - ScrollTemplate::DispelUndead => "& Scroll~| of Dispel Undead", - ScrollTemplate::DoorCreation => "& Scroll~| of Door Creation", - ScrollTemplate::DoorStairLocation => "& Scroll~| of Door/Stair Location", - ScrollTemplate::EnchantArmor => "& Scroll~| of Enchant Armor", - ScrollTemplate::EnchantWeapon => "& Scroll~| of Enchant Weapon", - ScrollTemplate::EnchantWeaponToDam => "& Scroll~| of Enchant Weapon To Dam", - ScrollTemplate::EnchantWeaponToHit => "& Scroll~| of Enchant Weapon To Hit", - ScrollTemplate::FeignDeath => "& Scroll~| of Feign Death", - ScrollTemplate::Genocide => "G& Scroll~| of enocide", - ScrollTemplate::HolyChant => "& Scroll~| of Holy Chant", - ScrollTemplate::HolyPrayer => "& Scroll~| of Holy Prayer", - ScrollTemplate::Identify => "& Scroll~| of Identify", - ScrollTemplate::Light => "& Scroll~| of Light", - ScrollTemplate::MagicMapping => "& Scroll~| of Magic Mapping", - ScrollTemplate::MakeMunchies => "& Scroll~| of Make Munchies", - ScrollTemplate::MassGenocide => "& Scroll~| of Mass Genocide", - ScrollTemplate::MonsterConfusion => "& Scroll~| of Monster Confusion", - ScrollTemplate::ObjectDetection => "& Scroll~| of Object Detection", - ScrollTemplate::PhaseDoor => "& Scroll~| of Phase Door", - ScrollTemplate::ProtectionFromEvil => "& Scroll~| of Protection from Evil", - ScrollTemplate::Recharging => "& Scroll~| of Recharging", - ScrollTemplate::RemoveCurse => "& Scroll~| of Remove Curse", - ScrollTemplate::RuneOfProtection => "& Scroll~| of Rune of Protection", - ScrollTemplate::SleepMonster => "& Scroll~| of Sleep Monster", - ScrollTemplate::SummonMonster => "& Scroll~| of Summon Monster", - ScrollTemplate::SummonUndead => "& Scroll~| of Summon Undead", - ScrollTemplate::Teleport => "& Scroll~| of Teleport", - ScrollTemplate::TeleportLevel => "& Scroll~| of Teleport Level", - ScrollTemplate::TrapCreation => "& Scroll~| of Trap Creation", - ScrollTemplate::TrapDetection => "& Scroll~| of Trap Detection", - ScrollTemplate::TrapDoorDestruction => "& Scroll~| of Trap/Door Destruction", - ScrollTemplate::TreasureDetection => "& Scroll~| of Treasure Detection", - ScrollTemplate::Wishing => "& Scroll~| of Wishing", - ScrollTemplate::WordOfRecall => "& Scroll~| of Word of Recall", + pub fn from(subval: i64) -> Box { + match subval { + 300 => Box::new(ScrollTemplate::AggravateMonster), + 301 => Box::new(ScrollTemplate::Blessing), + 302 => Box::new(ScrollTemplate::CreateFood), + 303 => Box::new(ScrollTemplate::CurseArmor), + 304 => Box::new(ScrollTemplate::CurseWeapon), + 305 => Box::new(ScrollTemplate::Darkness), + 306 => Box::new(ScrollTemplate::Destruction), + 307 => Box::new(ScrollTemplate::DetectInvisible), + 308 => Box::new(ScrollTemplate::DispelUndead), + 309 => Box::new(ScrollTemplate::DoorCreation), + 310 => Box::new(ScrollTemplate::DoorStairLocation), + 311 => Box::new(ScrollTemplate::EnchantArmor), + 312 => Box::new(ScrollTemplate::EnchantWeapon), + 313 => Box::new(ScrollTemplate::EnchantWeaponToDam), + 314 => Box::new(ScrollTemplate::EnchantWeaponToHit), + 315 => Box::new(ScrollTemplate::FeignDeath), + 316 => Box::new(ScrollTemplate::Genocide), + 317 => Box::new(ScrollTemplate::HolyChant), + 318 => Box::new(ScrollTemplate::HolyPrayer), + 319 => Box::new(ScrollTemplate::Identify), + 320 => Box::new(ScrollTemplate::Light), + 321 => Box::new(ScrollTemplate::MagicMapping), + 322 => Box::new(ScrollTemplate::MakeMunchies), + 323 => Box::new(ScrollTemplate::MassGenocide), + 324 => Box::new(ScrollTemplate::MonsterConfusion), + 325 => Box::new(ScrollTemplate::ObjectDetection), + 326 => Box::new(ScrollTemplate::PhaseDoor), + 327 => Box::new(ScrollTemplate::ProtectionFromEvil), + 328 => Box::new(ScrollTemplate::Recharging), + 329 => Box::new(ScrollTemplate::RemoveCurse), + 330 => Box::new(ScrollTemplate::RuneOfProtection), + 331 => Box::new(ScrollTemplate::SleepMonster), + 332 => Box::new(ScrollTemplate::SummonMonster), + 333 => Box::new(ScrollTemplate::SummonUndead), + 334 => Box::new(ScrollTemplate::Teleport), + 335 => Box::new(ScrollTemplate::TeleportLevel), + 336 => Box::new(ScrollTemplate::TrapCreation), + 337 => Box::new(ScrollTemplate::TrapDetection), + 338 => Box::new(ScrollTemplate::TrapDoorDestruction), + 339 => Box::new(ScrollTemplate::TreasureDetection), + 340 => Box::new(ScrollTemplate::Wishing), + 341 => Box::new(ScrollTemplate::WordOfRecall), + _ => panic!("subval {} out of bounds", subval), } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::Scroll1 } +impl item_template::ItemTemplate for ScrollTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Scroll } fn flags1(&self) -> u64 { match self { @@ -296,48 +296,48 @@ impl item_template::ItemTemplate for ScrollTemplate { fn subtype(&self) -> i64 { match self { - ScrollTemplate::AggravateMonster => 277, - ScrollTemplate::Blessing => 262, - ScrollTemplate::CreateFood => 285, - ScrollTemplate::CurseArmor => 260, - ScrollTemplate::CurseWeapon => 258, - ScrollTemplate::Darkness => 283, - ScrollTemplate::Destruction => 266, - ScrollTemplate::DetectInvisible => 276, - ScrollTemplate::DispelUndead => 286, - ScrollTemplate::DoorCreation => 280, - ScrollTemplate::DoorStairLocation => 274, - ScrollTemplate::EnchantArmor => 259, - ScrollTemplate::EnchantWeapon => 258, - ScrollTemplate::EnchantWeaponToDam => 257, - ScrollTemplate::EnchantWeaponToHit => 257, - ScrollTemplate::FeignDeath => 268, - ScrollTemplate::Genocide => 282, - ScrollTemplate::HolyChant => 263, - ScrollTemplate::HolyPrayer => 264, - ScrollTemplate::Identify => 260, - ScrollTemplate::Light => 262, - ScrollTemplate::MagicMapping => 268, - ScrollTemplate::MakeMunchies => 269, - ScrollTemplate::MassGenocide => 275, - ScrollTemplate::MonsterConfusion => 267, - ScrollTemplate::ObjectDetection => 272, - ScrollTemplate::PhaseDoor => 264, - ScrollTemplate::ProtectionFromEvil => 284, - ScrollTemplate::Recharging => 281, - ScrollTemplate::RemoveCurse => 261, - ScrollTemplate::RuneOfProtection => 270, - ScrollTemplate::SleepMonster => 269, - ScrollTemplate::SummonMonster => 263, - ScrollTemplate::SummonUndead => 261, - ScrollTemplate::Teleport => 266, - ScrollTemplate::TeleportLevel => 265, - ScrollTemplate::TrapCreation => 278, - ScrollTemplate::TrapDetection => 273, - ScrollTemplate::TrapDoorDestruction => 279, - ScrollTemplate::TreasureDetection => 271, - ScrollTemplate::Wishing => 267, - ScrollTemplate::WordOfRecall => 265, + ScrollTemplate::AggravateMonster => 300, + ScrollTemplate::Blessing => 301, + ScrollTemplate::CreateFood => 302, + ScrollTemplate::CurseArmor => 303, + ScrollTemplate::CurseWeapon => 304, + ScrollTemplate::Darkness => 305, + ScrollTemplate::Destruction => 306, + ScrollTemplate::DetectInvisible => 307, + ScrollTemplate::DispelUndead => 308, + ScrollTemplate::DoorCreation => 309, + ScrollTemplate::DoorStairLocation => 310, + ScrollTemplate::EnchantArmor => 311, + ScrollTemplate::EnchantWeapon => 312, + ScrollTemplate::EnchantWeaponToDam => 313, + ScrollTemplate::EnchantWeaponToHit => 314, + ScrollTemplate::FeignDeath => 315, + ScrollTemplate::Genocide => 316, + ScrollTemplate::HolyChant => 317, + ScrollTemplate::HolyPrayer => 318, + ScrollTemplate::Identify => 319, + ScrollTemplate::Light => 320, + ScrollTemplate::MagicMapping => 321, + ScrollTemplate::MakeMunchies => 322, + ScrollTemplate::MassGenocide => 323, + ScrollTemplate::MonsterConfusion => 324, + ScrollTemplate::ObjectDetection => 325, + ScrollTemplate::PhaseDoor => 326, + ScrollTemplate::ProtectionFromEvil => 327, + ScrollTemplate::Recharging => 328, + ScrollTemplate::RemoveCurse => 329, + ScrollTemplate::RuneOfProtection => 330, + ScrollTemplate::SleepMonster => 331, + ScrollTemplate::SummonMonster => 332, + ScrollTemplate::SummonUndead => 333, + ScrollTemplate::Teleport => 334, + ScrollTemplate::TeleportLevel => 335, + ScrollTemplate::TrapCreation => 336, + ScrollTemplate::TrapDetection => 337, + ScrollTemplate::TrapDoorDestruction => 338, + ScrollTemplate::TreasureDetection => 339, + ScrollTemplate::Wishing => 340, + ScrollTemplate::WordOfRecall => 341, } } diff --git a/src/item_template/shield.rs b/src/item_template/shield.rs index bc6acf64..efea6708 100644 --- a/src/item_template/shield.rs +++ b/src/item_template/shield.rs @@ -32,24 +32,24 @@ impl ShieldTemplate { pub fn iter() -> impl Iterator> { ShieldTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for ShieldTemplate { - fn name(&self) -> &str { - match self { - ShieldTemplate::SmallLeatherShield => "Small Leather Shield^ [%P6,%P4]", - ShieldTemplate::MediumLeatherShield => "Medium Leather Shield^ [%P6,%P4]", - ShieldTemplate::LargeLeatherShield => "Large Leather Shield^ [%P6,%P4]", - ShieldTemplate::Buckler => "Buckler^ [%P6,%P4]", - ShieldTemplate::KiteShield => "Kite Shield^ [%P6,%P4]", - ShieldTemplate::TowerShield => "Tower Shield^ [%P6,%P4]", - ShieldTemplate::SharkskinShield => "Sharkskin Shield^ [%P6,%P4]", - ShieldTemplate::DemonhideShield => "Demonhide Shield^ [%P6,%P4]", - ShieldTemplate::WyrmhideShield => "Wyrmhide Shield^ [%P6,%P4]", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(ShieldTemplate::SmallLeatherShield), + 2 => Box::new(ShieldTemplate::MediumLeatherShield), + 3 => Box::new(ShieldTemplate::LargeLeatherShield), + 4 => Box::new(ShieldTemplate::Buckler), + 5 => Box::new(ShieldTemplate::KiteShield), + 6 => Box::new(ShieldTemplate::TowerShield), + 7 => Box::new(ShieldTemplate::SharkskinShield), + 8 => Box::new(ShieldTemplate::DemonhideShield), + 9 => Box::new(ShieldTemplate::WyrmhideShield), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for ShieldTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Shield } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/sling.rs b/src/item_template/sling.rs index 99fa3e66..2e962316 100644 --- a/src/item_template/sling.rs +++ b/src/item_template/sling.rs @@ -17,16 +17,17 @@ impl SlingTemplate { pub fn iter() -> impl Iterator> { SlingTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for SlingTemplate { - fn name(&self) -> &str { - match self { - SlingTemplate::Sling => "Sling (%P0)^ (%P2,%P3)", - } + pub fn from(subval: i64) -> Box { + match subval { + 20 => Box::new(SlingTemplate::Sling), + _ => panic!("subval {} out of bounds", subval), + } } +} - fn item_type(&self) -> model::ItemType { model::ItemType::RangedWeapon } +impl item_template::ItemTemplate for SlingTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::Sling } fn flags1(&self) -> u64 { 0 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/song_book.rs b/src/item_template/song_book.rs index 8afcccf5..14305eb2 100644 --- a/src/item_template/song_book.rs +++ b/src/item_template/song_book.rs @@ -22,19 +22,19 @@ impl SongBookTemplate { pub fn iter() -> impl Iterator> { SongBookTemplate::vec().into_iter() } -} - -impl item_template::ItemTemplate for SongBookTemplate { - fn name(&self) -> &str { - match self { - SongBookTemplate::BeginnersHandbook => "& Book of Bard Lyrics [Beginners Handbook]", - SongBookTemplate::SongBook1 => "& Songs of Charming [Song Book I]", - SongBookTemplate::SongBook2 => "& Ballads of Knowledge [Song Book II]", - SongBookTemplate::GreaterSongBook => "& Epics of the Bards [Greater Song Book]", + pub fn from(subval: i64) -> Box { + match subval { + 262 => Box::new(SongBookTemplate::BeginnersHandbook), + 263 => Box::new(SongBookTemplate::SongBook1), + 264 => Box::new(SongBookTemplate::SongBook2), + 265 => Box::new(SongBookTemplate::GreaterSongBook), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for SongBookTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::SongBook } fn flags1(&self) -> u64 { diff --git a/src/item_template/staff.rs b/src/item_template/staff.rs index 8c738e8e..371fdffe 100644 --- a/src/item_template/staff.rs +++ b/src/item_template/staff.rs @@ -63,38 +63,39 @@ impl StaffTemplate { pub fn iter() -> impl Iterator> { StaffTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for StaffTemplate { - fn name(&self) -> &str { - match self { - StaffTemplate::StaffOfLight => "& Staff| of Light^ (%P1 charges)", - StaffTemplate::StaffOfDoorStairLocation => "& Staff| of Door/Stair Location^ (%P1 charges)", - StaffTemplate::StaffOfTrapLocation => "& Staff| of Trap Location^ (%P1 charges)", - StaffTemplate::StaffOfTreasureLocation => "& Staff| of Treasure Location^ (%P1 charges)", - StaffTemplate::StaffOfObjectLocation => "& Staff| of Object Location^ (%P1 charges)", - StaffTemplate::StaffOfTeleportation => "& Staff| of Teleportation^ (%P1 charges)", - StaffTemplate::StaffOfEarthquakes => "& Staff| of Earthquakes^ (%P1 charges)", - StaffTemplate::StaffOfSummoning => "& Staff| of Summoning^ (%P1 charges)", - StaffTemplate::StaffOfDestruction => "& Staff| of *Destruction*^ (%P1 charges)", - StaffTemplate::StaffOfStarlite => "& Staff| of Starlite^ (%P1 charges)", - StaffTemplate::StaffOfHasteMonsters => "& Staff| of Haste Monsters^ (%P1 charges)", - StaffTemplate::StaffOfSlowMonsters => "& Staff| of Slow Monsters^ (%P1 charges)", - StaffTemplate::StaffOfSleepMonsters => "& Staff| of Sleep Monsters^ (%P1 charges)", - StaffTemplate::StaffOfCureLightWounds => "& Staff| of Cure Light Wounds^ (%P1 charges)", - StaffTemplate::StaffOfDetectInvisible => "& Staff| of Detect Invisible^ (%P1 charges)", - StaffTemplate::StaffOfSpeed => "& Staff| of Speed^ (%P1 charges)", - StaffTemplate::StaffOfSlowness => "& Staff| of Slowness^ (%P1 charges)", - StaffTemplate::StaffOfMassPolymorph => "& Staff| of Mass Polymorph^ (%P1 charges)", - StaffTemplate::StaffOfRemoveCurse => "& Staff| of Remove Curse^ (%P1 charges)", - StaffTemplate::StaffOfDetectEvil => "& Staff| of Detect Evil^ (%P1 charges)", - StaffTemplate::StaffOfCuring => "& Staff| of Curing^ (%P1 charges)", - StaffTemplate::StaffOfDispelEvil => "& Staff| of Dispel Evil^ (%P1 charges)", - StaffTemplate::StaffOfDarkness => "& Staff| of Darkness^ (%P1 charges)", - StaffTemplate::StaffOfIdentify => "& Staff| of Identify^ (%P1 charges)", + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(StaffTemplate::StaffOfLight), + 2 => Box::new(StaffTemplate::StaffOfDoorStairLocation), + 3 => Box::new(StaffTemplate::StaffOfTrapLocation), + 4 => Box::new(StaffTemplate::StaffOfTreasureLocation), + 5 => Box::new(StaffTemplate::StaffOfObjectLocation), + 6 => Box::new(StaffTemplate::StaffOfTeleportation), + 7 => Box::new(StaffTemplate::StaffOfEarthquakes), + 8 => Box::new(StaffTemplate::StaffOfSummoning), + 10 => Box::new(StaffTemplate::StaffOfDestruction), + 11 => Box::new(StaffTemplate::StaffOfStarlite), + 12 => Box::new(StaffTemplate::StaffOfHasteMonsters), + 13 => Box::new(StaffTemplate::StaffOfSlowMonsters), + 14 => Box::new(StaffTemplate::StaffOfSleepMonsters), + 15 => Box::new(StaffTemplate::StaffOfCureLightWounds), + 16 => Box::new(StaffTemplate::StaffOfDetectInvisible), + 17 => Box::new(StaffTemplate::StaffOfSpeed), + 18 => Box::new(StaffTemplate::StaffOfSlowness), + 19 => Box::new(StaffTemplate::StaffOfMassPolymorph), + 20 => Box::new(StaffTemplate::StaffOfRemoveCurse), + 21 => Box::new(StaffTemplate::StaffOfDetectEvil), + 22 => Box::new(StaffTemplate::StaffOfCuring), + 23 => Box::new(StaffTemplate::StaffOfDispelEvil), + 25 => Box::new(StaffTemplate::StaffOfDarkness), + 26 => Box::new(StaffTemplate::StaffOfIdentify), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for StaffTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Staff } fn flags1(&self) -> u64 { 0 } diff --git a/src/item_template/sword.rs b/src/item_template/sword.rs index 149a74f7..a5a6eee4 100644 --- a/src/item_template/sword.rs +++ b/src/item_template/sword.rs @@ -43,28 +43,29 @@ impl SwordTemplate { pub fn iter() -> impl Iterator> { SwordTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for SwordTemplate { - fn name(&self) -> &str { - match self { - SwordTemplate::Backsword => "Backsword (%P0)^ (%P2,%P3)", - SwordTemplate::BastardSword => "Bastard Sword (%P0)^ (%P2,%P3)", - SwordTemplate::Broadsword => "Broadsword (%P0)^ (%P2,%P3)", - SwordTemplate::Claymore => "Claymore (%P0)^ (%P2,%P3)", - SwordTemplate::Cutlass => "Cutlass (%P0)^ (%P2,%P3)", - SwordTemplate::Espadon => "Espadon (%P0)^ (%P2,%P3)", - SwordTemplate::ExecutionersSword => "Executioner's Sword (%P0)^ (%P2,%P3)", - SwordTemplate::Flamberge => "Flamberge (%P0)^ (%P2,%P3)", - SwordTemplate::Katana => "Katana (%P0)^ (%P2,%P3)", - SwordTemplate::Longsword => "Longsword (%P0)^ (%P2,%P3)", - SwordTemplate::Nodachi => "No-Dachi (%P0)^ (%P2,%P3)", - SwordTemplate::Sabre => "Sabre (%P0)^ (%P2,%P3)", - SwordTemplate::Zweihander => "Zweihander (%P0)^ (%P2,%P3)", - SwordTemplate::BrokenSword => "Broken Sword (%P0)^ (%P2,%P3)", + pub fn from(subval: i64) -> Box { + match subval { + 6 => Box::new(SwordTemplate::Backsword), + 7 => Box::new(SwordTemplate::BastardSword), + 10 => Box::new(SwordTemplate::Broadsword), + 11 => Box::new(SwordTemplate::Claymore), + 12 => Box::new(SwordTemplate::Cutlass), + 13 => Box::new(SwordTemplate::Espadon), + 14 => Box::new(SwordTemplate::ExecutionersSword), + 15 => Box::new(SwordTemplate::Flamberge), + 17 => Box::new(SwordTemplate::Katana), + 18 => Box::new(SwordTemplate::Longsword), + 19 => Box::new(SwordTemplate::Nodachi), + 21 => Box::new(SwordTemplate::Sabre), + 23 => Box::new(SwordTemplate::Zweihander), + 24 => Box::new(SwordTemplate::BrokenSword), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for SwordTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Sword } fn flags1(&self) -> u64 { 0x10000000 } fn flags2(&self) -> u64 { 0 } diff --git a/src/item_template/template.rs b/src/item_template/template.rs index 5a91b498..9dbc9b89 100644 --- a/src/item_template/template.rs +++ b/src/item_template/template.rs @@ -1,10 +1,10 @@ use misc; use model; +use item_template; pub trait ItemTemplate { fn create(&self) -> model::Item { model::Item { - name: misc::rs2item_name(self.name()), tval: self.item_type() as u8, flags: self.flags1(), flags2: self.flags2(), @@ -23,7 +23,6 @@ pub trait ItemTemplate { } } - fn name(&self) -> &str; fn item_type(&self) -> model::ItemType; fn flags1(&self) -> u64; fn flags2(&self) -> u64; @@ -40,3 +39,79 @@ pub trait ItemTemplate { fn item_level(&self) -> u8; fn is_identified(&self) -> bool; } + +impl dyn ItemTemplate { + pub fn from(item_type: model::ItemType, subval: i64) -> Box { + match item_type { + model::ItemType::MiscObject(_) => item_template::MiscTemplate::from(subval), + model::ItemType::Chest(_) => item_template::ChestTemplate::from(subval), + model::ItemType::MiscUsable(_) => item_template::MiscUsableTemplate::from(subval), + model::ItemType::Spike(_) => item_template::MiscUsableTemplate::from(subval), + model::ItemType::FlaskOfOil(_) => item_template::MiscUsableTemplate::from(subval), + model::ItemType::Jewelry(_) => item_template::JewelryTemplate::from(subval), + model::ItemType::Bag(_) => item_template::BagTemplate::from(subval), + model::ItemType::Gem(_) => item_template::GemTemplate::from(subval), + model::ItemType::WearableGem(_) => item_template::WearableGemTemplate::from(subval), + model::ItemType::SlingAmmo(_) => item_template::AmmunitionTemplate::from(subval), + model::ItemType::Bolt(_) => item_template::AmmunitionTemplate::from(subval), + model::ItemType::Arrow(_) => item_template::AmmunitionTemplate::from(subval), + model::ItemType::LightSource(_) => item_template::LightSourceTemplate::from(subval), + + model::ItemType::Bow(_) => item_template::BowTemplate::from(subval), + model::ItemType::Crossbow(_) => item_template::CrossbowTemplate::from(subval), + model::ItemType::Sling(_) => item_template::SlingTemplate::from(subval), + + model::ItemType::Axe(_) => item_template::AxeTemplate::from(subval), + model::ItemType::Polearm(_) => item_template::PolearmTemplate::from(subval), + model::ItemType::Dagger(_) => item_template::DaggerTemplate::from(subval), + model::ItemType::Sword(_) => item_template::SwordTemplate::from(subval), + model::ItemType::Pick(_) => item_template::PickTemplate::from(subval), + model::ItemType::Mace(_) => item_template::MaceTemplate::from(subval), + + model::ItemType::Boots(_) => item_template::BootsTemplate::from(subval), + model::ItemType::Gloves(_) => item_template::GlovesTemplate::from(subval), + model::ItemType::Cloak(_) => item_template::CloakTemplate::from(subval), + model::ItemType::Helm(_) => item_template::HelmTemplate::from(subval), + model::ItemType::Shield(_) => item_template::ShieldTemplate::from(subval), + model::ItemType::HardArmor(_) => item_template::HardArmorTemplate::from(subval), + model::ItemType::SoftArmor(_) => item_template::SoftArmorTemplate::from(subval), + model::ItemType::Bracers(_) => item_template::BracersTemplate::from(subval), + model::ItemType::Belt(_) => item_template::BeltTemplate::from(subval), + + model::ItemType::Amulet(_) => item_template::AmuletTemplate::from(subval), + model::ItemType::Ring(_) => item_template::RingTemplate::from(subval), + + model::ItemType::Staff(_) => item_template::StaffTemplate::from(subval), + model::ItemType::Wand(_) => item_template::WandTemplate::from(subval), + + model::ItemType::Scroll(_) => item_template::ScrollTemplate::from(subval), + model::ItemType::Potion(_) => item_template::PotionTemplate::from(subval), + model::ItemType::Food(_) => item_template::FoodTemplate::from(subval), + model::ItemType::JunkFood(_) => item_template::JunkFoodTemplate::from(subval), + + model::ItemType::Chime(_) => item_template::ChimeTemplate::from(subval), + model::ItemType::Horn(_) => item_template::HornTemplate::from(subval), + + model::ItemType::MagicBook(_) => item_template::MagicBookTemplate::from(subval), + model::ItemType::PrayerBook(_) => item_template::PrayerBookTemplate::from(subval), + model::ItemType::Instrument(_) => item_template::InstrumentTemplate::from(subval), + model::ItemType::SongBook(_) => item_template::SongBookTemplate::from(subval), + + // Not Items, but yeah + model::ItemType::LodgingAtInn(_) => item_template::LodgingAtInnTemplate::from(subval), + model::ItemType::Money(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::UnseenTrap(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::SeenTrap(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::Rubble(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::OpenDoor(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::ClosedDoor(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::UpStaircase(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::DownStaircase(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::SecretDoor(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::EntranceToStore(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::UpSteepStaircase(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::DownSteepStaircase(_) => item_template::DungeonFeatureTemplate::from(subval), + model::ItemType::Whirlpool(_) => item_template::DungeonFeatureTemplate::from(subval), + } + } +} diff --git a/src/item_template/valuable.rs b/src/item_template/valuable.rs deleted file mode 100644 index 6bc60f99..00000000 --- a/src/item_template/valuable.rs +++ /dev/null @@ -1,364 +0,0 @@ -use model; -use item_template; - -#[derive(Copy, Clone, Eq, PartialEq, Hash)] -pub enum ValuableTemplate { - GemOfTeleportation, - GemOfResistCold, - GemOfResistAcid, - GemOfSeeInvisible, - GemOfStealth, - GemOfSlowDigestion, - GemOfProtectFire, - GemOfDetectMonsters, - GemOfDispelEvil, - GemOfDarkness, - GemOfAcidBalls, - GemOfDetectInvisible, - GemOfIdentify, - GemOfLight, - GemOfSummoning, - GemOfRemoveCurse, - GemOfAnnihilation, - GemOfRecall, - FineAgate, - FineDiamond, - RoughDiamond, - RoughSapphire, - FineSapphire, - SmallBagOfOpals, - SmallBagOfSapphires, - SmallPouchOfDiamonds, - LargeSackOfPearls, - LargeSackOfSapphires, - LargePouchOfDiamonds, - SmallGoldPendant, - SmallMithrilPendant, - LargeMithrilGarterBelt, - SmallSilverPendant, -} - -impl ValuableTemplate { - pub fn vec() -> Vec> { - vec![ - Box::new(ValuableTemplate::GemOfTeleportation), - Box::new(ValuableTemplate::GemOfResistCold), - Box::new(ValuableTemplate::GemOfResistAcid), - Box::new(ValuableTemplate::GemOfSeeInvisible), - Box::new(ValuableTemplate::GemOfStealth), - Box::new(ValuableTemplate::GemOfSlowDigestion), - Box::new(ValuableTemplate::GemOfProtectFire), - Box::new(ValuableTemplate::GemOfDetectMonsters), - Box::new(ValuableTemplate::GemOfDispelEvil), - Box::new(ValuableTemplate::GemOfDarkness), - Box::new(ValuableTemplate::GemOfAcidBalls), - Box::new(ValuableTemplate::GemOfDetectInvisible), - Box::new(ValuableTemplate::GemOfIdentify), - Box::new(ValuableTemplate::GemOfLight), - Box::new(ValuableTemplate::GemOfSummoning), - Box::new(ValuableTemplate::GemOfRemoveCurse), - Box::new(ValuableTemplate::GemOfAnnihilation), - Box::new(ValuableTemplate::GemOfRecall), - Box::new(ValuableTemplate::FineAgate), - Box::new(ValuableTemplate::FineDiamond), - Box::new(ValuableTemplate::RoughDiamond), - Box::new(ValuableTemplate::RoughSapphire), - Box::new(ValuableTemplate::FineSapphire), - Box::new(ValuableTemplate::SmallBagOfOpals), - Box::new(ValuableTemplate::SmallBagOfSapphires), - Box::new(ValuableTemplate::SmallPouchOfDiamonds), - Box::new(ValuableTemplate::LargeSackOfPearls), - Box::new(ValuableTemplate::LargeSackOfSapphires), - Box::new(ValuableTemplate::LargePouchOfDiamonds), - Box::new(ValuableTemplate::SmallGoldPendant), - Box::new(ValuableTemplate::SmallMithrilPendant), - Box::new(ValuableTemplate::LargeMithrilGarterBelt), - Box::new(ValuableTemplate::SmallSilverPendant), - ] - } - - pub fn iter() -> impl Iterator> { - ValuableTemplate::vec().into_iter() - } -} - -impl item_template::ItemTemplate for ValuableTemplate { - fn name(&self) -> &str { - match self { - ValuableTemplate::GemOfTeleportation => "& Finely cut| of Teleportation^", - ValuableTemplate::GemOfResistCold => "& Finely cut| of Resist Cold^", - ValuableTemplate::GemOfResistAcid => "& Finely cut| of Resist Acid^", - ValuableTemplate::GemOfSeeInvisible => "& Finely cut| of See Invisible^", - ValuableTemplate::GemOfStealth => "& Finely cut| of Stealth^", - ValuableTemplate::GemOfSlowDigestion => "& Finely cut| of Slow Digestion^", - ValuableTemplate::GemOfProtectFire => "& Finely cut| of Lordly Protection (FIRE)^", - ValuableTemplate::GemOfDetectMonsters => "& Finely cut| of Detect Monsters^ (%P1 charges)", - ValuableTemplate::GemOfDispelEvil => "& Finely cut| of Dispel Evil^ (%P1 charges)", - ValuableTemplate::GemOfDarkness => "& Finely cut| of Darkness^ (%P1 charges)", - ValuableTemplate::GemOfAcidBalls => "& Finely cut| of Acid Balls^ (%P1 charges)", - ValuableTemplate::GemOfDetectInvisible => "& Finely cut| of Detect Invisible^ (%P1 charges)", - ValuableTemplate::GemOfIdentify => "& Finely cut| of Identify^ (%P1 charges)", - ValuableTemplate::GemOfLight => "& Finely cut| of Light^ (%P1 charges)", - ValuableTemplate::GemOfSummoning => "& Finely cut| of Summoning^ (%P1 charges)", - ValuableTemplate::GemOfRemoveCurse => "& Finely cut| of Remove Curse^ (%P1 charges)", - ValuableTemplate::GemOfAnnihilation => "& Finely cut| of Annihilation^ (%P1 charges)", - ValuableTemplate::GemOfRecall => "& Finely cut| of Recall^ (%P1 charges)", - ValuableTemplate::FineAgate => "& Finely cut Agate~^", - ValuableTemplate::FineDiamond => "& Finely cut Diamond~^", - ValuableTemplate::RoughDiamond => "& Rough cut Diamond~^", - ValuableTemplate::RoughSapphire => "& Rough cut Sapphire~^", - ValuableTemplate::FineSapphire => "& Finely cut Sapphire~^", - ValuableTemplate::SmallBagOfOpals => "& Small bag~ of Opals^", - ValuableTemplate::SmallBagOfSapphires => "& Small bag~ of Sapphires^", - ValuableTemplate::SmallPouchOfDiamonds => "& Small pouch~ of Diamonds^", - ValuableTemplate::LargeSackOfPearls => "& Large sack~ of Pearls^", - ValuableTemplate::LargeSackOfSapphires => "& Large sack~ of Sapphires^", - ValuableTemplate::LargePouchOfDiamonds => "& Large pouch~ of Diamonds^", - ValuableTemplate::SmallGoldPendant => "& Small gold pendant~^", - ValuableTemplate::SmallMithrilPendant => "& Small mithril pendant~^", - ValuableTemplate::LargeMithrilGarterBelt => "& Large mithril garter-belt~^", - ValuableTemplate::SmallSilverPendant => "& Small silver pendant~", - } - } - - fn item_type(&self) -> model::ItemType { - match self { - ValuableTemplate::GemOfTeleportation => model::ItemType::WearableGem, - ValuableTemplate::GemOfResistCold => model::ItemType::WearableGem, - ValuableTemplate::GemOfResistAcid => model::ItemType::WearableGem, - ValuableTemplate::GemOfSeeInvisible => model::ItemType::WearableGem, - ValuableTemplate::GemOfStealth => model::ItemType::WearableGem, - ValuableTemplate::GemOfSlowDigestion => model::ItemType::WearableGem, - ValuableTemplate::GemOfProtectFire => model::ItemType::WearableGem, - ValuableTemplate::GemOfDetectMonsters => model::ItemType::Gem, - ValuableTemplate::GemOfDispelEvil => model::ItemType::Gem, - ValuableTemplate::GemOfDarkness => model::ItemType::Gem, - ValuableTemplate::GemOfAcidBalls => model::ItemType::Gem, - ValuableTemplate::GemOfDetectInvisible => model::ItemType::Gem, - ValuableTemplate::GemOfIdentify => model::ItemType::Gem, - ValuableTemplate::GemOfLight => model::ItemType::Gem, - ValuableTemplate::GemOfSummoning => model::ItemType::Gem, - ValuableTemplate::GemOfRemoveCurse => model::ItemType::Gem, - ValuableTemplate::GemOfAnnihilation => model::ItemType::Gem, - ValuableTemplate::GemOfRecall => model::ItemType::Gem, - ValuableTemplate::FineAgate => model::ItemType::Gem, - ValuableTemplate::FineDiamond => model::ItemType::Gem, - ValuableTemplate::RoughDiamond => model::ItemType::Gem, - ValuableTemplate::RoughSapphire => model::ItemType::Gem, - ValuableTemplate::FineSapphire => model::ItemType::Gem, - ValuableTemplate::SmallBagOfOpals => model::ItemType::Gem, - ValuableTemplate::SmallBagOfSapphires => model::ItemType::Gem, - ValuableTemplate::SmallPouchOfDiamonds => model::ItemType::Gem, - ValuableTemplate::LargeSackOfPearls => model::ItemType::Gem, - ValuableTemplate::LargeSackOfSapphires => model::ItemType::Gem, - ValuableTemplate::LargePouchOfDiamonds => model::ItemType::Gem, - ValuableTemplate::SmallGoldPendant => model::ItemType::Jewelry, - ValuableTemplate::SmallMithrilPendant => model::ItemType::Jewelry, - ValuableTemplate::LargeMithrilGarterBelt => model::ItemType::Jewelry, - ValuableTemplate::SmallSilverPendant => model::ItemType::Jewelry, - } - } - - fn flags1(&self) -> u64 { 0 } - - fn flags2(&self) -> u64 { - match self { - ValuableTemplate::GemOfTeleportation => 0x00000400, - ValuableTemplate::GemOfResistCold => 0x00200000, - ValuableTemplate::GemOfResistAcid => 0x00100000, - ValuableTemplate::GemOfSeeInvisible => 0x01000000, - ValuableTemplate::GemOfStealth => 0x00000100, - ValuableTemplate::GemOfSlowDigestion => 0x00000800, - ValuableTemplate::GemOfProtectFire => 0x00000800, - ValuableTemplate::GemOfDetectMonsters => 0x00040000, - ValuableTemplate::GemOfDispelEvil => 0x00080000, - ValuableTemplate::GemOfDarkness => 0x00100000, - ValuableTemplate::GemOfAcidBalls => 0x00200000, - ValuableTemplate::GemOfDetectInvisible => 0x00400000, - ValuableTemplate::GemOfIdentify => 0x00800000, - ValuableTemplate::GemOfLight => 0x01000000, - ValuableTemplate::GemOfSummoning => 0x02000000, - ValuableTemplate::GemOfRemoveCurse => 0x04000000, - ValuableTemplate::GemOfAnnihilation => 0x08000000, - ValuableTemplate::GemOfRecall => 0x10000000, - ValuableTemplate::FineAgate => 0, - ValuableTemplate::FineDiamond => 0, - ValuableTemplate::RoughDiamond => 0, - ValuableTemplate::RoughSapphire => 0, - ValuableTemplate::FineSapphire => 0, - ValuableTemplate::SmallBagOfOpals => 0, - ValuableTemplate::SmallBagOfSapphires => 0, - ValuableTemplate::SmallPouchOfDiamonds => 0, - ValuableTemplate::LargeSackOfPearls => 0, - ValuableTemplate::LargeSackOfSapphires => 0, - ValuableTemplate::LargePouchOfDiamonds => 0, - ValuableTemplate::SmallGoldPendant => 0, - ValuableTemplate::SmallMithrilPendant => 0, - ValuableTemplate::LargeMithrilGarterBelt => 0, - ValuableTemplate::SmallSilverPendant => 0, - } - } - - fn p1(&self) -> i64 { 0 } - - fn cost(&self) -> i64 { - match self { - ValuableTemplate::GemOfTeleportation => 300, - ValuableTemplate::GemOfResistCold => 250, - ValuableTemplate::GemOfResistAcid => 250, - ValuableTemplate::GemOfSeeInvisible => 350, - ValuableTemplate::GemOfStealth => 300, - ValuableTemplate::GemOfSlowDigestion => 200, - ValuableTemplate::GemOfProtectFire => 1200, - ValuableTemplate::GemOfDetectMonsters => 350, - ValuableTemplate::GemOfDispelEvil => 1200, - ValuableTemplate::GemOfDarkness => 0, - ValuableTemplate::GemOfAcidBalls => 1800, - ValuableTemplate::GemOfDetectInvisible => 225, - ValuableTemplate::GemOfIdentify => 400, - ValuableTemplate::GemOfLight => 300, - ValuableTemplate::GemOfSummoning => 0, - ValuableTemplate::GemOfRemoveCurse => 700, - ValuableTemplate::GemOfAnnihilation => 1000, - ValuableTemplate::GemOfRecall => 1200, - ValuableTemplate::FineAgate => 50, - ValuableTemplate::FineDiamond => 500, - ValuableTemplate::RoughDiamond => 100, - ValuableTemplate::RoughSapphire => 40, - ValuableTemplate::FineSapphire => 250, - ValuableTemplate::SmallBagOfOpals => 250, - ValuableTemplate::SmallBagOfSapphires => 450, - ValuableTemplate::SmallPouchOfDiamonds => 1000, - ValuableTemplate::LargeSackOfPearls => 650, - ValuableTemplate::LargeSackOfSapphires => 600, - ValuableTemplate::LargePouchOfDiamonds => 2000, - ValuableTemplate::SmallGoldPendant => 75, - ValuableTemplate::SmallMithrilPendant => 350, - ValuableTemplate::LargeMithrilGarterBelt => 1500, - ValuableTemplate::SmallSilverPendant => 60, - } - } - - fn subtype(&self) -> i64 { - match self { - ValuableTemplate::GemOfTeleportation => 1, - ValuableTemplate::GemOfResistCold => 2, - ValuableTemplate::GemOfResistAcid => 3, - ValuableTemplate::GemOfSeeInvisible => 4, - ValuableTemplate::GemOfStealth => 5, - ValuableTemplate::GemOfSlowDigestion => 6, - ValuableTemplate::GemOfProtectFire => 7, - ValuableTemplate::GemOfDetectMonsters => 1, - ValuableTemplate::GemOfDispelEvil => 2, - ValuableTemplate::GemOfDarkness => 3, - ValuableTemplate::GemOfAcidBalls => 4, - ValuableTemplate::GemOfDetectInvisible => 5, - ValuableTemplate::GemOfIdentify => 6, - ValuableTemplate::GemOfLight => 7, - ValuableTemplate::GemOfSummoning => 8, - ValuableTemplate::GemOfRemoveCurse => 9, - ValuableTemplate::GemOfAnnihilation => 10, - ValuableTemplate::GemOfRecall => 11, - ValuableTemplate::FineAgate => 257, - ValuableTemplate::FineDiamond => 258, - ValuableTemplate::RoughDiamond => 259, - ValuableTemplate::RoughSapphire => 260, - ValuableTemplate::FineSapphire => 261, - ValuableTemplate::SmallBagOfOpals => 262, - ValuableTemplate::SmallBagOfSapphires => 263, - ValuableTemplate::SmallPouchOfDiamonds => 264, - ValuableTemplate::LargeSackOfPearls => 265, - ValuableTemplate::LargeSackOfSapphires => 266, - ValuableTemplate::LargePouchOfDiamonds => 267, - ValuableTemplate::SmallGoldPendant => 274, - ValuableTemplate::SmallMithrilPendant => 275, - ValuableTemplate::LargeMithrilGarterBelt => 276, - ValuableTemplate::SmallSilverPendant => 266, - } - } - - fn weight(&self) -> u16 { - match self { - ValuableTemplate::GemOfTeleportation => 5, - ValuableTemplate::GemOfResistCold => 5, - ValuableTemplate::GemOfResistAcid => 5, - ValuableTemplate::GemOfSeeInvisible => 5, - ValuableTemplate::GemOfStealth => 5, - ValuableTemplate::GemOfSlowDigestion => 5, - ValuableTemplate::GemOfProtectFire => 5, - ValuableTemplate::GemOfDetectMonsters => 5, - ValuableTemplate::GemOfDispelEvil => 5, - ValuableTemplate::GemOfDarkness => 5, - ValuableTemplate::GemOfAcidBalls => 5, - ValuableTemplate::GemOfDetectInvisible => 5, - ValuableTemplate::GemOfIdentify => 5, - ValuableTemplate::GemOfLight => 5, - ValuableTemplate::GemOfSummoning => 5, - ValuableTemplate::GemOfRemoveCurse => 5, - ValuableTemplate::GemOfAnnihilation => 5, - ValuableTemplate::GemOfRecall => 5, - ValuableTemplate::FineAgate => 5, - ValuableTemplate::FineDiamond => 5, - ValuableTemplate::RoughDiamond => 5, - ValuableTemplate::RoughSapphire => 5, - ValuableTemplate::FineSapphire => 5, - ValuableTemplate::SmallBagOfOpals => 5, - ValuableTemplate::SmallBagOfSapphires => 5, - ValuableTemplate::SmallPouchOfDiamonds => 5, - ValuableTemplate::LargeSackOfPearls => 35, - ValuableTemplate::LargeSackOfSapphires => 5, - ValuableTemplate::LargePouchOfDiamonds => 5, - ValuableTemplate::SmallGoldPendant => 5, - ValuableTemplate::SmallMithrilPendant => 5, - ValuableTemplate::LargeMithrilGarterBelt => 5, - ValuableTemplate::SmallSilverPendant => 5, - } - } - - fn number(&self) -> u16 { 1 } - fn modifier_to_hit(&self) -> i16 { 0 } - fn modifier_to_damage(&self) -> i16 { 0 } - fn base_ac(&self) -> i16 { 0 } - fn modifier_to_ac(&self) -> i16 { 0 } - fn damage(&self) -> &str { "1d1" } - - fn item_level(&self) -> u8 { - match self { - ValuableTemplate::GemOfTeleportation => 5, - ValuableTemplate::GemOfResistCold => 14, - ValuableTemplate::GemOfResistAcid => 14, - ValuableTemplate::GemOfSeeInvisible => 40, - ValuableTemplate::GemOfStealth => 35, - ValuableTemplate::GemOfSlowDigestion => 14, - ValuableTemplate::GemOfProtectFire => 40, - ValuableTemplate::GemOfDetectMonsters => 14, - ValuableTemplate::GemOfDispelEvil => 49, - ValuableTemplate::GemOfDarkness => 7, - ValuableTemplate::GemOfAcidBalls => 50, - ValuableTemplate::GemOfDetectInvisible => 47, - ValuableTemplate::GemOfIdentify => 40, - ValuableTemplate::GemOfLight => 2, - ValuableTemplate::GemOfSummoning => 3, - ValuableTemplate::GemOfRemoveCurse => 25, - ValuableTemplate::GemOfAnnihilation => 40, - ValuableTemplate::GemOfRecall => 22, - ValuableTemplate::FineAgate => 5, - ValuableTemplate::FineDiamond => 35, - ValuableTemplate::RoughDiamond => 15, - ValuableTemplate::RoughSapphire => 7, - ValuableTemplate::FineSapphire => 12, - ValuableTemplate::SmallBagOfOpals => 10, - ValuableTemplate::SmallBagOfSapphires => 15, - ValuableTemplate::SmallPouchOfDiamonds => 45, - ValuableTemplate::LargeSackOfPearls => 25, - ValuableTemplate::LargeSackOfSapphires => 30, - ValuableTemplate::LargePouchOfDiamonds => 65, - ValuableTemplate::SmallGoldPendant => 5, - ValuableTemplate::SmallMithrilPendant => 10, - ValuableTemplate::LargeMithrilGarterBelt => 45, - ValuableTemplate::SmallSilverPendant => 5, - } - } - - fn is_identified(&self) -> bool { false } -} diff --git a/src/item_template/wand.rs b/src/item_template/wand.rs index 2b7beba8..f82143ab 100644 --- a/src/item_template/wand.rs +++ b/src/item_template/wand.rs @@ -64,39 +64,40 @@ impl WandTemplate { pub fn iter() -> impl Iterator> { WandTemplate::vec().into_iter() } -} -impl item_template::ItemTemplate for WandTemplate { - fn name(&self) -> &str { - match self { - WandTemplate::WandOfProbing => "& Wand| of Probing^ (%P1 charges)", - WandTemplate::WandOfLight => "& Wand| of Light^ (%P1 charges)", - WandTemplate::WandOfLightningBolts => "& Wand| of Lightning Bolts^ (%P1 charges)", - WandTemplate::WandOfFrostBolts => "& Wand| of Frost Bolts^ (%P1 charges)", - WandTemplate::WandOfFireBolts => "& Wand| of Fire Bolts^ (%P1 charges)", - WandTemplate::WandOfStoneToMud => "& Wand| of Stone-to-Mud^ (%P1 charges)", - WandTemplate::WandOfPolymorph => "& Wand| of Polymorph^ (%P1 charges)", - WandTemplate::WandOfHealMonster => "& Wand| of Heal Monster^ (%P1 charges)", - WandTemplate::WandOfHasteMonster => "& Wand| of Haste Monster^ (%P1 charges)", - WandTemplate::WandOfSlowMonster => "& Wand| of Slow Monster^ (%P1 charges)", - WandTemplate::WandOfConfuseMonster => "& Wand| of Confuse Monster^ (%P1 charges)", - WandTemplate::WandOfSleepMonster => "& Wand| of Sleep Monster^ (%P1 charges)", - WandTemplate::WandOfDrainLife => "& Wand| of Drain Life^ (%P1 charges)", - WandTemplate::WandOfTrapDoorDestruction => "& Wand| of Trap/Door destruction^ (%P1 charges)", - WandTemplate::WandOfMagicMissile => "& Wand| of Magic Missile^ (%P1 charges)", - WandTemplate::WandOfWallBuilding => "& Wand| of Wall Building^ (%P1 charges)", - WandTemplate::WandOfCloneMonster => "& Wand| of Clone Monster^ (%P1 charges)", - WandTemplate::WandOfTeleportAway => "& Wand| of Teleport Away^ (%P1 charges)", - WandTemplate::WandOfDisarming => "& Wand| of Disarming^ (%P1 charges)", - WandTemplate::WandOfLightningBalls => "& Wand| of Lightning Balls^ (%P1 charges)", - WandTemplate::WandOfColdBalls => "& Wand| of Cold Balls^ (%P1 charges)", - WandTemplate::WandOfFireBalls => "& Wand| of Fire Balls^ (%P1 charges)", - WandTemplate::WandOfStinkingCloud => "& Wand| of Stinking Cloud^ (%P1 charges)", - WandTemplate::WandOfAcidBalls => "& Wand| of Acid Balls^ (%P1 charges)", - WandTemplate::WandOfWonder => "& Wand| of Wonder^ (%P1 charges)", + pub fn from(subval: i64) -> Box { + match subval { + 25 => Box::new(WandTemplate::WandOfProbing), + 1 => Box::new(WandTemplate::WandOfLight), + 2 => Box::new(WandTemplate::WandOfLightningBolts), + 3 => Box::new(WandTemplate::WandOfFrostBolts), + 4 => Box::new(WandTemplate::WandOfFireBolts), + 5 => Box::new(WandTemplate::WandOfStoneToMud), + 6 => Box::new(WandTemplate::WandOfPolymorph), + 7 => Box::new(WandTemplate::WandOfHealMonster), + 8 => Box::new(WandTemplate::WandOfHasteMonster), + 9 => Box::new(WandTemplate::WandOfSlowMonster), + 10 => Box::new(WandTemplate::WandOfConfuseMonster), + 11 => Box::new(WandTemplate::WandOfSleepMonster), + 12 => Box::new(WandTemplate::WandOfDrainLife), + 13 => Box::new(WandTemplate::WandOfTrapDoorDestruction), + 14 => Box::new(WandTemplate::WandOfMagicMissile), + 15 => Box::new(WandTemplate::WandOfWallBuilding), + 16 => Box::new(WandTemplate::WandOfCloneMonster), + 17 => Box::new(WandTemplate::WandOfTeleportAway), + 18 => Box::new(WandTemplate::WandOfDisarming), + 19 => Box::new(WandTemplate::WandOfLightningBalls), + 20 => Box::new(WandTemplate::WandOfColdBalls), + 21 => Box::new(WandTemplate::WandOfFireBalls), + 22 => Box::new(WandTemplate::WandOfStinkingCloud), + 23 => Box::new(WandTemplate::WandOfAcidBalls), + 24 => Box::new(WandTemplate::WandOfWonder), + _ => panic!("subval {} out of bounds", subval), } } +} +impl item_template::ItemTemplate for WandTemplate { fn item_type(&self) -> model::ItemType { model::ItemType::Wand } fn flags1(&self) -> u64 { 0 } diff --git a/src/item_template/wearable_gem.rs b/src/item_template/wearable_gem.rs new file mode 100644 index 00000000..f7af1b8a --- /dev/null +++ b/src/item_template/wearable_gem.rs @@ -0,0 +1,121 @@ +use model; +use item_template; + +#[derive(Copy, Clone, Eq, PartialEq, Hash)] +pub enum WearableGemTemplate { + GemOfTeleportation, + GemOfResistCold, + GemOfResistAcid, + GemOfSeeInvisible, + GemOfStealth, + GemOfSlowDigestion, + GemOfProtectFire, +} + +impl WearableGemTemplate { + pub fn vec() -> Vec> { + vec![ + Box::new(WearableGemTemplate::GemOfTeleportation), + Box::new(WearableGemTemplate::GemOfResistCold), + Box::new(WearableGemTemplate::GemOfResistAcid), + Box::new(WearableGemTemplate::GemOfSeeInvisible), + Box::new(WearableGemTemplate::GemOfStealth), + Box::new(WearableGemTemplate::GemOfSlowDigestion), + Box::new(WearableGemTemplate::GemOfProtectFire), + ] + } + + pub fn iter() -> impl Iterator> { + WearableGemTemplate::vec().into_iter() + } + + pub fn from(subval: i64) -> Box { + match subval { + 1 => Box::new(WearableGemTemplate::GemOfTeleportation), + 2 => Box::new(WearableGemTemplate::GemOfResistCold), + 3 => Box::new(WearableGemTemplate::GemOfResistAcid), + 4 => Box::new(WearableGemTemplate::GemOfSeeInvisible), + 5 => Box::new(WearableGemTemplate::GemOfStealth), + 6 => Box::new(WearableGemTemplate::GemOfSlowDigestion), + 7 => Box::new(WearableGemTemplate::GemOfProtectFire), + _ => panic!("subval {} out of bounds", subval), + } + } +} + +impl item_template::ItemTemplate for WearableGemTemplate { + fn item_type(&self) -> model::ItemType { model::ItemType::WearableGem } + fn flags1(&self) -> u64 { 0 } + + fn flags2(&self) -> u64 { + match self { + WearableGemTemplate::GemOfTeleportation => 0x00000400, + WearableGemTemplate::GemOfResistCold => 0x00200000, + WearableGemTemplate::GemOfResistAcid => 0x00100000, + WearableGemTemplate::GemOfSeeInvisible => 0x01000000, + WearableGemTemplate::GemOfStealth => 0x00000100, + WearableGemTemplate::GemOfSlowDigestion => 0x00000800, + WearableGemTemplate::GemOfProtectFire => 0x00000800, + } + } + + fn p1(&self) -> i64 { 0 } + + fn cost(&self) -> i64 { + match self { + WearableGemTemplate::GemOfTeleportation => 300, + WearableGemTemplate::GemOfResistCold => 250, + WearableGemTemplate::GemOfResistAcid => 250, + WearableGemTemplate::GemOfSeeInvisible => 350, + WearableGemTemplate::GemOfStealth => 300, + WearableGemTemplate::GemOfSlowDigestion => 200, + WearableGemTemplate::GemOfProtectFire => 1200, + } + } + + fn subtype(&self) -> i64 { + match self { + WearableGemTemplate::GemOfTeleportation => 1, + WearableGemTemplate::GemOfResistCold => 2, + WearableGemTemplate::GemOfResistAcid => 3, + WearableGemTemplate::GemOfSeeInvisible => 4, + WearableGemTemplate::GemOfStealth => 5, + WearableGemTemplate::GemOfSlowDigestion => 6, + WearableGemTemplate::GemOfProtectFire => 7, + } + } + + fn weight(&self) -> u16 { + match self { + WearableGemTemplate::GemOfTeleportation => 5, + WearableGemTemplate::GemOfResistCold => 5, + WearableGemTemplate::GemOfResistAcid => 5, + WearableGemTemplate::GemOfSeeInvisible => 5, + WearableGemTemplate::GemOfStealth => 5, + WearableGemTemplate::GemOfSlowDigestion => 5, + WearableGemTemplate::GemOfProtectFire => 5, + } + } + + fn number(&self) -> u16 { 1 } + fn modifier_to_hit(&self) -> i16 { 0 } + fn modifier_to_damage(&self) -> i16 { 0 } + fn base_ac(&self) -> i16 { 0 } + fn modifier_to_ac(&self) -> i16 { 0 } + fn damage(&self) -> &str { "1d1" } + + fn item_level(&self) -> u8 { + match self { + WearableGemTemplate::GemOfTeleportation => 5, + WearableGemTemplate::GemOfResistCold => 14, + WearableGemTemplate::GemOfResistAcid => 14, + WearableGemTemplate::GemOfSeeInvisible => 40, + WearableGemTemplate::GemOfStealth => 35, + WearableGemTemplate::GemOfSlowDigestion => 14, + WearableGemTemplate::GemOfProtectFire => 40, + } + } + + fn is_identified(&self) -> bool { false } +} + diff --git a/src/lib.rs b/src/lib.rs index 6d6b7d18..6c51d945 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,6 +21,7 @@ pub mod dungeon; pub mod equipment; pub mod error; pub mod highscore; +pub mod identification; pub mod io; pub mod logic; pub mod magic; diff --git a/src/logic/generate_item.rs b/src/logic/generate_item.rs index cfefaae8..6967f981 100644 --- a/src/logic/generate_item.rs +++ b/src/logic/generate_item.rs @@ -64,7 +64,8 @@ pub fn generate_item_for_general_store() -> model::Item { pub fn generate_item_for_armorsmith() -> model::Item { let mut templates: Vec> = Vec::new(); - templates.extend(item_template::ArmorTemplate::vec()); + templates.extend(item_template::HardArmorTemplate::vec()); + templates.extend(item_template::SoftArmorTemplate::vec()); templates.extend(item_template::BootsTemplate::vec()); templates.extend(item_template::GlovesTemplate::vec()); templates.extend(item_template::HelmTemplate::vec()); @@ -166,7 +167,9 @@ pub fn generate_item_for_gem_store() -> model::Item { templates.extend(item_template::AmuletTemplate::vec()); templates.extend(item_template::RingTemplate::vec()); - templates.extend(item_template::ValuableTemplate::vec()); + templates.extend(item_template::JewelryTemplate::vec()); + templates.extend(item_template::GemTemplate::vec()); + templates.extend(item_template::WearableGemTemplate::vec()); templates = templates.into_iter() .filter(|x| x.item_level() <= constants::STORE_MAX_ITEM_LEVEL) @@ -242,10 +245,10 @@ pub fn generate_item_for_item_level(item_level: u8) -> model::Item { DungeonItems, // MiscObject, Chest Jewelry, // Jewelry, Gems, Ring, Amulet MagicItem, // Wand, Rod, Staff, Chime, Horn - Potion, // Potion1, Potion2 - Scroll, // Scroll1, Scroll2 + Potion, + Scroll, Usable, // FlaskOfOil, SlingAmmo, Bolt, Arrow, Spike, Bag, LightSource, MiscUsable - Weapon, // RangedWeapon, HafterWeapon, PoleArm, Dagger, Sword, Pick, Maul + Weapon, // RangedWeapon, HafterWeapon, Polearm, Dagger, Sword, Pick, Maul } let item_type = match rand::random::() % 100 { @@ -276,7 +279,8 @@ pub fn generate_item_for_item_level(item_level: u8) -> model::Item { let mut templates: Vec> = Vec::new(); match item_type { GenTreasureType::Armor => { - templates.extend(item_template::ArmorTemplate::vec()); + templates.extend(item_template::HardArmorTemplate::vec()); + templates.extend(item_template::SoftArmorTemplate::vec()); templates.extend(item_template::BootsTemplate::vec()); templates.extend(item_template::BeltTemplate::vec()); templates.extend(item_template::BracersTemplate::vec()); @@ -291,8 +295,10 @@ pub fn generate_item_for_item_level(item_level: u8) -> model::Item { }, GenTreasureType::Jewelry => { templates.extend(item_template::AmuletTemplate::vec()); - templates.extend(item_template::ValuableTemplate::vec()); + templates.extend(item_template::JewelryTemplate::vec()); templates.extend(item_template::RingTemplate::vec()); + templates.extend(item_template::GemTemplate::vec()); + templates.extend(item_template::WearableGemTemplate::vec()); }, GenTreasureType::MagicItem => { templates.extend(item_template::ChimeTemplate::vec()); diff --git a/src/logic/item_name/helpers.rs b/src/logic/item_name/helpers.rs new file mode 100644 index 00000000..4cbb165e --- /dev/null +++ b/src/logic/item_name/helpers.rs @@ -0,0 +1,92 @@ +use std::borrow::Cow; + +use model; +use misc; + +pub fn plural_s<'a>(item: &model::Item) -> Cow<'a, str> { + Cow::from(if item.number == 1 { + "" + } else { + "s" + }) +} + +pub fn plural_es<'a>(item: &model::Item) -> Cow<'a, str> { + Cow::from(if item.number == 1 { + "" + } else { + "es" + }) +} + +pub fn armor<'a>(item: &model::Item) -> Cow<'a, str> { + if item.ac == 0 && (!item.is_identified() || item.toac == 0) { + return Cow::from(""); + } + + if !item.is_identified() { + return Cow::from(format!(" [{}]", item.ac)); + } + + let toac_sign = if item.toac > 0 { "+" } else {""}; + return Cow::from(format!(" [{},{}{}]", item.ac, toac_sign, item.toac)) +} + +pub fn attack_enchantment<'a>(item: &model::Item) -> Cow<'a, str> { + if !item.is_identified() { + return Cow::from(""); + } + + let tohit_sign = if item.tohit > 0 { "+" } else {""}; + let todam_sign = if item.todam > 0 { "+" } else {""}; + Cow::from(format!(" ({}{},{}{})", tohit_sign, item.tohit, todam_sign, item.todam)) +} + +pub fn damage<'a>(item: &model::Item) -> Cow<'a, str> { + let raw_string = item.damage.iter().map(|&i| i as u8).collect::>(); + let damage_string = misc::c_array_to_rust_string(raw_string); + Cow::from(format!(" ({})", damage_string)) +} + +pub fn number_of<'a>(item: &model::Item) -> Cow<'a, str> { + match item.number { + 0 => Cow::from("no more "), + 1 => Cow::from(""), + _ => Cow::from(item.number.to_string() + " "), + } +} + +pub fn charges<'a>(item: &model::Item) -> Cow<'a, str> { + if !item.is_identified() { + return Cow::from(""); + } + return Cow::from(format!(" ({} charges)", item.p1)) +} + +pub fn p1<'a>(item: &model::Item) -> Cow<'a, str> { + if !item.is_identified() { + return Cow::from(""); + } + return Cow::from(format!(" ({})", item.p1)) +} + +pub fn to_hit<'a>(item: &model::Item) -> Cow<'a, str> { + if !item.is_identified() { + return Cow::from(""); + } + return Cow::from(format!(" ({})", item.tohit)) +} + +pub fn to_damage<'a>(item: &model::Item) -> Cow<'a, str> { + if !item.is_identified() { + return Cow::from(""); + } + return Cow::from(format!(" ({})", item.todam)) +} + +pub fn to_ac<'a>(item: &model::Item) -> Cow<'a, str> { + if !item.is_identified() { + return Cow::from(""); + } + return Cow::from(format!(" ({})", item.toac)) +} diff --git a/src/logic/item_name/item_name.rs b/src/logic/item_name/item_name.rs new file mode 100644 index 00000000..ffe74305 --- /dev/null +++ b/src/logic/item_name/item_name.rs @@ -0,0 +1,1402 @@ +use std::borrow::Cow; + +use item_template; +use model; +use identification; + +use super::helpers; + +pub fn generate_book_name<'a>(item: &model::Item, name: Cow<'a, str>) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(name); + parts.join("") +} + +pub fn generate_weapon_name<'a>(item: &model::Item, name: Cow<'a, str>) -> String { + let mut parts = Vec::new(); + parts.push(name); + parts.push(helpers::damage(&item)); + parts.push(helpers::attack_enchantment(&item)); + parts.push(helpers::armor(&item)); + if item.flags & 0x01598001 == 0x01598001{ + parts.push(Cow::from(" (HA)")); + } else if item.flags & 0x07B80900 == 0x07B80900 { + parts.push(Cow::from(" (DF)")); + } else if item.flags & 0x00080000 == 0x00080000 && item.flags2 & 0x00000001 == 0x00000001 { + parts.push(Cow::from(" (DB)")); + } else if item.flags & 0x01000838 == 0x01000838 && item.flags2 & 0x00200002 == 0x00200002 { + parts.push(Cow::from(" (SS)")); + } else if item.flags & 0x00400000 == 0x00400000 && item.flags2 & 0x00000040 == 0x00000040 { + parts.push(Cow::from(" (V)")); + } else if item.flags & 0x00300960 == 0x00300960 { + parts.push(Cow::from(" of Trollkind")); + } else if item.flags & 0x01004000 == 0x01004000 { + parts.push(Cow::from(" (SM)")); + } else if item.flags & 0x00002000 == 0x00002000 { + parts.push(Cow::from(" (SD)")); + } else if item.flags & 0x00004000 == 0x00004000 { + parts.push(Cow::from(" of Slay Monster")); + } else if item.flags & 0x00008000 == 0x00008000 { + parts.push(Cow::from(" of Slay Evil")); + } else if item.flags & 0x00010000 == 0x00010000 { + parts.push(Cow::from(" (SU)")); + } else if item.flags & 0x00020000 == 0x00020000 { + parts.push(Cow::from(" (FB)")); + } else if item.flags & 0x00040000 == 0x00040000 { + parts.push(Cow::from(" (FT)")); + } else if item.flags2 & 0x00000010 == 0x00000010 { + if let model::ItemType::Dagger(_) = item.item_type() { + parts.push(Cow::from(" (WB)")); + } else if let model::ItemType::Mace(_) = item.item_type() { + parts.push(Cow::from(" (BB)")); + } else { + parts.push(Cow::from(" (Magic)")); + } + } else if item.flags2 & 0x00000004 == 0x00000004 { + parts.push(Cow::from(" (SR)")); + } else if item.flags2 & 0x00000040 == 0x00000040 { + parts.push(Cow::from(" of Criticals")); + } else if item.tohit > 4 && item.todam > 4 { + parts.push(Cow::from(" of Slaying")); + } + parts.join("") +} + +pub fn generate_armor_name<'a>(item: &model::Item, name: Cow<'a, str>) -> String { + let mut parts = Vec::new(); + parts.push(name); + if item.tohit != 0 || item.todam != 0 { + parts.push(helpers::attack_enchantment(&item)); + } + parts.push(helpers::armor(&item)); + if item.flags & 0x02380000 == 0x02380000 { + parts.push(Cow::from(" (R)")); + } else if item.flags & 0x00800007 == 0x00800007 { + parts.push(Cow::from(" of Might")); + } else if item.flags & 0x00800007 == 0x00800007 { + parts.push(Cow::from(" of the Magi")); + } else if item.flags & 0x00000030 == 0x00000030 { + parts.push(Cow::from(" of Lordliness")); + } else if item.flags & 0x41800040 == 0x41800040 { + parts.push(Cow::from(" of Hobbitkind")); + } else if item.flags & 0x01400120 == 0x01400120 { + parts.push(Cow::from(" of Elvenkin")); + } else if item.flags & 0x60400000 == 0x60400000 && item.flags2 & 0x00000010 == 0x00000010 { + parts.push(Cow::from(" of Dwarvenkind")); + } else if item.flags & 0x05800020 == 0x05800020 && item.flags2 & 0x00000010 == 0x00000010 { + parts.push(Cow::from(" of Dryadkind")); + } else if item.flags & 0x03B80800 == 0x03B80800 && item.flags2 & 0x00000010 == 0x00000010 { + parts.push(Cow::from(" of Titan Strength")); + } else if item.flags & 0x03100000 == 0x03100000 { + if item.flags2 & 0x00000010 == 0x00000010 { + parts.push(Cow::from(" of Storm Giant Strength")); + } else { + parts.push(Cow::from(" of Cloud Giant Strength")); + } + } else if item.flags & 0x01080000 == 0x01080000 { + parts.push(Cow::from(" of Fire Giant Strength")); + } else if item.flags & 0x01200000 == 0x01200000 { + parts.push(Cow::from(" of Frost Giant Strength")); + } else if item.flags & 0x01000000 == 0x01000000 { + if item.p1 > 1 { + parts.push(Cow::from(" of Stone Giant Strength")); + } else { + parts.push(Cow::from(" of Hill Giant Strength")); + } + } else if item.flags & 0x00000081 == 0x00000081 { + parts.push(Cow::from(" of Ogre Power")); + } else if item.flags & 0x01000040 == 0x01000040 { + parts.push(Cow::from(" of Seeing")); + } else if item.flags & 0x9800073F == 0x9800073F && item.flags2 & 0x80400000 == 0x80400000 { + parts.push(Cow::from(" of **TOTAL DOOM**")); + } else if item.flags & 0x80000001 == 0x80000001 { + parts.push(Cow::from(" of Weakness")); + } else if item.flags & 0x80000002 == 0x80000002 { + parts.push(Cow::from(" of Clumsiness")); + } else if item.flags & 0x80000008 == 0x80000008 { + parts.push(Cow::from(" of Stupidity")); + } else if item.flags & 0x80000010 == 0x80000010 { + parts.push(Cow::from(" of Dullness")); + } else if item.flags & 0x80000020 == 0x80000020 { + parts.push(Cow::from(" of Ugliness")); + } else if item.flags & 0x80000200 == 0x80000200 { + parts.push(Cow::from(" of Noise")); + } else if item.flags & 0x80000400 == 0x80000400 { + parts.push(Cow::from(" of Teleportation")); + } else if item.flags & 0x80001000 == 0x80001000 { + parts.push(Cow::from(" of Slowness")); + } else if item.flags & 0x80400000 == 0x80400000 { + parts.push(Cow::from(" of Hunger")); + } else if item.flags & 0x88000000 == 0x88000000 { + parts.push(Cow::from(" of Blindness")); + } else if item.flags & 0x90000000 == 0x90000000 { + parts.push(Cow::from(" of Fear")); + } else if item.flags & 0x80000000 == 0x80000000 { + parts.push(Cow::from(" of Great Mass")); + } else if item.flags & 0x05000000 == 0x05000000 && item.flags2 & 0x00000020 == 0x00000020 { + parts.push(Cow::from(" of Thievery")); + } else if item.flags2 & 0x00000010 == 0x00000010 && item.toac > 0 { + parts.push(Cow::from(" of Deflection")); + } else if item.flags & 0x00400080 == 0x00400080 { + parts.push(Cow::from(" of Improved Digestion")); + } else if item.flags & 0x00100000 == 0x00100000 { + parts.push(Cow::from(" (RA)")); + } else if item.flags & 0x00080000 == 0x00080000 { + parts.push(Cow::from(" (RF)")); + } else if item.flags & 0x00200000 == 0x00200000 { + parts.push(Cow::from(" (RC)")); + } else if item.flags & 0x02000000 == 0x02000000 { + parts.push(Cow::from(" (RL)")); + } else if item.flags & 0x00000002 == 0x00000002 { + parts.push(Cow::from(" of the Hive")); + } else if item.flags & 0x00001000 == 0x00001000 { + parts.push(Cow::from(" of Speed")); + } else if item.flags & 0x00000100 == 0x00000100 { + parts.push(Cow::from(" of Stealth")); + } else if item.flags & 0x00800000 == 0x00800000 { + parts.push(Cow::from(" of Free Action")); + } else if item.flags & 0x04000000 == 0x04000000 { + parts.push(Cow::from(" of Slow Descent")); + } else if item.tohit != 0 || item.todam != 0 { + parts.push(Cow::from(" of Slaying")); + } else if item.flags & 0x00000008 == 0x00000008 { + parts.push(Cow::from(" of Intelligence")); + } else if item.flags & 0x00000010 == 0x00000010 { + parts.push(Cow::from(" of Wisdom")); + } else if item.flags & 0x00000020 == 0x00000020 { + parts.push(Cow::from(" of Beauty")); + } else if item.flags & 0x40000000 == 0x40000000 { + parts.push(Cow::from(" of Infravision")); + } else if item.flags & 0x00000800 == 0x00000800 { + parts.push(Cow::from(" of Regeneration")); + } + parts.join("") +} + +fn misc_object_name(item: &model::Item, subtype: item_template::MiscTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(Cow::from(match subtype { + item_template::MiscTemplate::RatSkeleton => "Rat Skeleton", + item_template::MiscTemplate::GiantCentipedeSkeleton => "Giant Centipede Skeleton", + item_template::MiscTemplate::EmptyBottle => "Empty Bottle", + item_template::MiscTemplate::PotteryShard => "Some Shards of Pottery", + item_template::MiscTemplate::HumanSkeleton => "Human Skeleton", + item_template::MiscTemplate::DwarfSkeleton => "Dwarf Skeleton", + item_template::MiscTemplate::ElfSkeleton => "Elf Skeleton", + item_template::MiscTemplate::GnomeSkeleton => "Gnome Skeleton", + item_template::MiscTemplate::BrokenTeeth => "Broken Set of Teeth", + item_template::MiscTemplate::LargeBrokenBone => "Large Broken Bone", + item_template::MiscTemplate::BrokenStick => "Broken Stick", + })); + parts.join("") +} + +fn chest_name(item: &model::Item, subtype: item_template::ChestTemplate) -> String { + let mut parts = Vec::new(); + + parts.push(Cow::from(match subtype { + item_template::ChestTemplate::SmallWoodenChest => "Small wooden chest", + item_template::ChestTemplate::LargeWoodenChest => "Large wooden chest", + item_template::ChestTemplate::SmallIronChest => "Small iron chest", + item_template::ChestTemplate::LargeIronChest => "Large iron chest", + item_template::ChestTemplate::SmallSteelChest => "Small steel chest", + item_template::ChestTemplate::LargeSteelChest => "Large steel chest", + })); + + if item.is_identified() { + if item.subval == 5 { // Dead human body + parts.push(Cow::from(" (Looted)")); + } else if item.flags & 0x00000181 == 0x00000181 { + parts.push(Cow::from(" (Multiple Traps)")); + } else if item.flags & 0x00000071 == 0x00000071 { + parts.push(Cow::from(" (Multiple Traps)")); + } else if item.flags & 0x00000101 == 0x00000101 { + parts.push(Cow::from(" (Summoning Runes)")); + } else if item.flags & 0x00000081 == 0x00000081 { + parts.push(Cow::from(" (Explosion Device)")); + } else if item.flags & 0x00000041 == 0x00000041 { + parts.push(Cow::from(" (Gas Trap)")); + } else if item.flags & 0x00000021 == 0x00000021 { + parts.push(Cow::from(" (Poison Needle)")); + } else if item.flags & 0x00000011 == 0x00000011 { + parts.push(Cow::from(" (Poison Needle)")); + } else if item.flags & 0x00000001 == 0x00000001 { + parts.push(Cow::from(" (Locked)")); + } + } + parts.join("") +} + +fn misc_name(item: &model::Item, subtype: item_template::MiscUsableTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(match subtype { + item_template::MiscUsableTemplate::FlaskOfOil + => Cow::from(format!("Flask{} of Oil", helpers::plural_s(&item))), + item_template::MiscUsableTemplate::IronSpike + => Cow::from(format!("Iron Spike{}", helpers::plural_s(&item))), + item_template::MiscUsableTemplate::Statue + => Cow::from(format!("Iron Statue{}", helpers::plural_s(&item))), + item_template::MiscUsableTemplate::Teeth + => Cow::from("Teeth"), + item_template::MiscUsableTemplate::SilverCross + => Cow::from(format!("Silver Cross{}", helpers::plural_es(&item))), + item_template::MiscUsableTemplate::GoldCross + => Cow::from(format!("Gold Cross{}", helpers::plural_es(&item))), + item_template::MiscUsableTemplate::MithrilCross + => Cow::from(format!("Mithril Cross{}", helpers::plural_es(&item))), + item_template::MiscUsableTemplate::Cross + => Cow::from(format!("Iron Cross{}", helpers::plural_es(&item))), + item_template::MiscUsableTemplate::CorkedBottle + => Cow::from(format!("Corked Bottle{}", helpers::plural_s(&item))), + }); + + match subtype { + item_template::MiscUsableTemplate::Teeth => { + if item.flags & 0x20000000 == 0x20000000 { + parts.push(Cow::from(" from a Dragon")); + } else if item.flags & 0x40000000 == 0x40000000 { + parts.push(Cow::from(" of a Demon")); + } + }, + item_template::MiscUsableTemplate::Statue => { + if item.flags & 0x00000100 == 0x00000100 { + parts.push(Cow::from(" Major of Undead Summoning")); + } else if item.flags & 0x00000200 == 0x00000200 { + parts.push(Cow::from(" Major of Demon Summoning")); + } else if item.flags & 0x00000400 == 0x00000400 { + parts.push(Cow::from(" Life Giving")); + } + }, + item_template::MiscUsableTemplate::SilverCross | + item_template::MiscUsableTemplate::GoldCross | + item_template::MiscUsableTemplate::MithrilCross => { + if item.flags & 0x00000001 == 0x00000001 { + parts.push(Cow::from(" of Turning")); + } else if item.flags & 0x00000002 == 0x00000002 { + parts.push(Cow::from(" of Demon Dispelling")); + } + }, + item_template::MiscUsableTemplate::Cross => { + if item.flags & 0x00000004 == 0x00000004 { + parts.push(Cow::from(" of Summon Undead")); + } + }, + item_template::MiscUsableTemplate::CorkedBottle => { + if item.flags & 0x00000010 == 0x00000010 { + parts.push(Cow::from(" containing a Djinni")); + } else if item.flags & 0x00000020 == 0x00000020 { + parts.push(Cow::from(" containing some Demons")); + } + }, + _ => {}, + }; + parts.join("") +} + +fn jewelry_name(item: &model::Item, subtype: item_template::JewelryTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(Cow::from(match subtype { + item_template::JewelryTemplate::SmallGoldPendant + => format!("Small gold pendant{}", helpers::plural_s(&item)), + item_template::JewelryTemplate::SmallMithrilPendant + => format!("Small mithril pendant{}", helpers::plural_s(&item)), + item_template::JewelryTemplate::LargeMithrilGarterBelt + => format!("Large mithril garter-belt{}", helpers::plural_s(&item)), + item_template::JewelryTemplate::SmallSilverPendant + => format!("Small silver pendant{}", helpers::plural_s(&item)), + })); + parts.join("") +} + +fn bag_name(item: &model::Item, subtype: item_template::BagTemplate) -> String { + let mut parts = Vec::new(); + parts.push("Bag"); + + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(match subtype { + item_template::BagTemplate::BagOfHolding250 => " of Holding (250)", + item_template::BagTemplate::BagOfHolding500 => " of Holding (500)", + item_template::BagTemplate::BagOfHolding1000 => " of Holding (1000)", + item_template::BagTemplate::BagOfHolding1500 => " of Holding (1500)", + item_template::BagTemplate::BagOfDevouring => " of Devouring", + }); + } + parts.join("") +} + +fn gem_name(item: &model::Item, subtype: item_template::GemTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + + parts.push(match subtype { + item_template::GemTemplate::GemOfDetectMonsters | + item_template::GemTemplate::GemOfDispelEvil | + item_template::GemTemplate::GemOfDarkness | + item_template::GemTemplate::GemOfAcidBalls | + item_template::GemTemplate::GemOfDetectInvisible | + item_template::GemTemplate::GemOfIdentify | + item_template::GemTemplate::GemOfLight | + item_template::GemTemplate::GemOfSummoning | + item_template::GemTemplate::GemOfRemoveCurse | + item_template::GemTemplate::GemOfAnnihilation | + item_template::GemTemplate::GemOfRecall => + Cow::from("Finely Cut Gem"), + item_template::GemTemplate::FineAgate => + Cow::from(format!("Finely cut Agate{}", helpers::plural_s(&item))), + item_template::GemTemplate::FineDiamond => + Cow::from(format!("Finely cut Diamond{}", helpers::plural_s(&item))), + item_template::GemTemplate::RoughDiamond => + Cow::from(format!("Rough cut Diamond{}", helpers::plural_s(&item))), + item_template::GemTemplate::RoughSapphire => + Cow::from(format!("Rough cut Sapphire{}", helpers::plural_s(&item))), + item_template::GemTemplate::FineSapphire => + Cow::from(format!("Finely cut Sapphire{}", helpers::plural_s(&item))), + item_template::GemTemplate::SmallBagOfOpals => + Cow::from(format!("Small bag{} of Opals", helpers::plural_s(&item))), + item_template::GemTemplate::SmallBagOfSapphires => + Cow::from(format!("Small bag{} of Sapphires", helpers::plural_s(&item))), + item_template::GemTemplate::SmallPouchOfDiamonds => + Cow::from(format!("Small pouch{} of Diamonds", helpers::plural_s(&item))), + item_template::GemTemplate::LargeSackOfPearls => + Cow::from(format!("Large sack{} of Pearls", helpers::plural_s(&item))), + item_template::GemTemplate::LargeSackOfSapphires => + Cow::from(format!("Large sack{} of Sapphires", helpers::plural_s(&item))), + item_template::GemTemplate::LargePouchOfDiamonds => + Cow::from(format!("Large pouch{} of Diamonds", helpers::plural_s(&item))), + }); + + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::GemTemplate::GemOfDetectMonsters => " of Detect Monsters", + item_template::GemTemplate::GemOfDispelEvil => " of Dispel Evil", + item_template::GemTemplate::GemOfDarkness => " of Darkness", + item_template::GemTemplate::GemOfAcidBalls => " of Acid Balls", + item_template::GemTemplate::GemOfDetectInvisible => " of Detect Invisible", + item_template::GemTemplate::GemOfIdentify => " of Identify", + item_template::GemTemplate::GemOfLight => " of Light", + item_template::GemTemplate::GemOfSummoning => " of Summoning", + item_template::GemTemplate::GemOfRemoveCurse => " of Remove Curse", + item_template::GemTemplate::GemOfAnnihilation => " of Annihilation", + item_template::GemTemplate::GemOfRecall => " of Recall", + _ => "", + })); + } + + if item.is_identified() { + parts.push(match subtype { + item_template::GemTemplate::GemOfDetectMonsters | + item_template::GemTemplate::GemOfDispelEvil | + item_template::GemTemplate::GemOfDarkness | + item_template::GemTemplate::GemOfAcidBalls | + item_template::GemTemplate::GemOfDetectInvisible | + item_template::GemTemplate::GemOfIdentify | + item_template::GemTemplate::GemOfLight | + item_template::GemTemplate::GemOfSummoning | + item_template::GemTemplate::GemOfRemoveCurse | + item_template::GemTemplate::GemOfAnnihilation | + item_template::GemTemplate::GemOfRecall + => helpers::charges(item), + _ => Cow::from(""), + }); + } + parts.join("") +} + +fn wearable_gem_name(item: &model::Item, subtype: item_template::WearableGemTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(&item)); + parts.push(Cow::from("Finely cut Gem")); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::WearableGemTemplate::GemOfTeleportation => " of Teleportation", + item_template::WearableGemTemplate::GemOfResistCold => " of Resist Cold", + item_template::WearableGemTemplate::GemOfResistAcid => " of Resist Acid", + item_template::WearableGemTemplate::GemOfSeeInvisible => " of See Invisible", + item_template::WearableGemTemplate::GemOfStealth => " of Stealth", + item_template::WearableGemTemplate::GemOfSlowDigestion => " of Slow Digestion", + item_template::WearableGemTemplate::GemOfProtectFire => " of Lordly Protection (FIRE)", + })); + } + parts.join("") +} + +fn ammo_name(item: &model::Item, subtype: item_template::AmmunitionTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(Cow::from(match subtype { + item_template::AmmunitionTemplate::Arrow => + format!("Arrow{}", helpers::plural_s(&item)), + item_template::AmmunitionTemplate::Bolt => + format!("Bolt{}", helpers::plural_s(&item)), + item_template::AmmunitionTemplate::RoundedPebble => + format!("Rounded Pebble{}", helpers::plural_s(&item)), + item_template::AmmunitionTemplate::IronShot => + format!("Iron Shot{}", helpers::plural_s(&item)), + })); + parts.push(helpers::attack_enchantment(&item)); + parts.join("") +} + +fn light_source_name(item: &model::Item, subtype: item_template::LightSourceTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(&item)); + parts.push(match subtype { + item_template::LightSourceTemplate::WoodenTorch => + Cow::from(format!("Wooden Torch{}", helpers::plural_es(&item))), + item_template::LightSourceTemplate::BrassLantern => + Cow::from(format!("Brass Lantern{}", helpers::plural_s(&item))), + item_template::LightSourceTemplate::MagicTorch => + Cow::from("Magic Torch"), + item_template::LightSourceTemplate::MagicLantern => + Cow::from("Magic Lantern"), + }); + let turns_plural = if item.p1 == 1 { "" } else { "s" }; + parts.push(Cow::from(format!(" with {} turn{} of light", item.p1, turns_plural))); + parts.join("") +} + +fn bow_name(item: &model::Item, subtype: item_template::BowTemplate) -> String { + generate_weapon_name(item, Cow::from(match subtype { + item_template::BowTemplate::Shortbow => "Shortbow", + item_template::BowTemplate::HuntersBow => "Hunters Bow", + item_template::BowTemplate::CompositeBow => "Composite Bow", + item_template::BowTemplate::WarBow => "War Bow", + item_template::BowTemplate::DoubleBow => "Double Bow", + item_template::BowTemplate::SiegeBow => "Siege Bow", + item_template::BowTemplate::WardedBow => "Warded Bow", + })) +} + +fn crossbow_name(item: &model::Item, subtype: item_template::CrossbowTemplate) -> String { + generate_weapon_name(item, Cow::from(match subtype { + item_template::CrossbowTemplate::SiegeCrossbow => "Siege Crossbow", + item_template::CrossbowTemplate::Ballista => "Ballista", + item_template::CrossbowTemplate::LightCrossbow => "Light Crossbow", + item_template::CrossbowTemplate::HeavyCrossbow => "Heavy Crossbow", + })) +} + +fn sling_name(item: &model::Item, subtype: item_template::SlingTemplate) -> String { + let mut parts = Vec::new(); + parts.push(Cow::from("Sling")); + parts.push(helpers::damage(&item)); + parts.push(helpers::attack_enchantment(&item)); + parts.join("") +} + +fn axe_name(item: &model::Item, subtype: item_template::AxeTemplate) -> String { + generate_weapon_name(item, Cow::from(match subtype { + item_template::AxeTemplate::Balestarius => "Balestarius", + item_template::AxeTemplate::BattleAxe => "Battle Axe", + item_template::AxeTemplate::BroadAxe => "Broad Axe", + item_template::AxeTemplate::HandAxe => "Hand Axe", + item_template::AxeTemplate::WarAxe => "War Axe", + item_template::AxeTemplate::LargeAxe => "Large Axe", + item_template::AxeTemplate::BeardedAxe => "Bearded Axe", + item_template::AxeTemplate::SilverEdgedAxe => "Silved Edged Axe", + item_template::AxeTemplate::ChampionAxe => "Champion Axe", + })) +} + +fn polearm_name(item: &model::Item, subtype: item_template::PolearmTemplate) -> String { + generate_weapon_name(item, Cow::from(match subtype { + item_template::PolearmTemplate::AwlPike => "Awl-Pike", + item_template::PolearmTemplate::BeakedAxe => "Beaked Axe", + item_template::PolearmTemplate::Fauchard => "Fauchard", + item_template::PolearmTemplate::Glaive => "Glaive", + item_template::PolearmTemplate::Halberd => "Halberd", + item_template::PolearmTemplate::LucerneHammer => "Lucerne Hammer", + item_template::PolearmTemplate::Pike => "Pike", + item_template::PolearmTemplate::Spike => "Spear", + item_template::PolearmTemplate::Lance => "Lance", + item_template::PolearmTemplate::Javelin => "Javelin", + item_template::PolearmTemplate::Naginata => "Naginata", + item_template::PolearmTemplate::WarScythe => "War Scythe", + })) +} + +fn dagger_name(item: &model::Item, subtype: item_template::DaggerTemplate) -> String { + generate_weapon_name(item, Cow::from(match subtype { + item_template::DaggerTemplate::MainGauche =>"Main Gauche", + item_template::DaggerTemplate::Misercorde =>"Misercorde", + item_template::DaggerTemplate::Stiletto =>"Stiletto", + item_template::DaggerTemplate::Bodkin =>"Bodkin", + item_template::DaggerTemplate::BrokenDagger =>"Broken Dagger", + item_template::DaggerTemplate::CatONineTails =>"Cat-O-Nine Tails", + item_template::DaggerTemplate::Bilbo =>"Bilbo", + item_template::DaggerTemplate::Baselard =>"Baselard", + item_template::DaggerTemplate::Foil =>"Foil", + item_template::DaggerTemplate::Rapier =>"Rapier", + item_template::DaggerTemplate::SmallSword =>"Small Sword", + })) +} + +fn sword_name(item: &model::Item, subtype: item_template::SwordTemplate) -> String { + generate_weapon_name(item, Cow::from(match subtype { + item_template::SwordTemplate::Backsword => "Backsword", + item_template::SwordTemplate::BastardSword => "Bastard Sword", + item_template::SwordTemplate::Broadsword => "Broadsword", + item_template::SwordTemplate::Claymore => "Claymore", + item_template::SwordTemplate::Cutlass => "Cutlass", + item_template::SwordTemplate::Espadon => "Espadon", + item_template::SwordTemplate::ExecutionersSword => "Executioner's Sword", + item_template::SwordTemplate::Flamberge => "Flamberge", + item_template::SwordTemplate::Katana => "Katana", + item_template::SwordTemplate::Longsword => "Longsword", + item_template::SwordTemplate::Nodachi => "No-Dachi", + item_template::SwordTemplate::Sabre => "Sabre", + item_template::SwordTemplate::Zweihander => "Zweihander", + item_template::SwordTemplate::BrokenSword => "Broken Sword", + })) +} + +fn pick_name(item: &model::Item, subtype: item_template::PickTemplate) -> String { + generate_weapon_name(item, Cow::from(match subtype { + item_template::PickTemplate::Pick => "Pick", + item_template::PickTemplate::Shovel => "Shovel", + item_template::PickTemplate::OrcishPick1 => "Orcish Pick", + item_template::PickTemplate::OrcishPick2 => "Orcish Pick", + item_template::PickTemplate::DwarvenPick => "Dwarven Pick", + item_template::PickTemplate::GnomishShovel => "Gnomish Shovel", + item_template::PickTemplate::DwarvenShovel => "Dwarven Shovel", + })) +} + +fn mace_name(item: &model::Item, subtype: item_template::MaceTemplate) -> String { + generate_weapon_name(item, Cow::from(match subtype { + item_template::MaceTemplate::BallAndChain => "Ball and Chain", + item_template::MaceTemplate::WoodenClub => "Wooden Club", + item_template::MaceTemplate::Flail => "Flail", + item_template::MaceTemplate::GreatFlail => "Two Handed Great Flail", + item_template::MaceTemplate::MorningStar => "Morningstar", + item_template::MaceTemplate::Mace => "Mace", + item_template::MaceTemplate::WarHammer => "War Hammer", + item_template::MaceTemplate::LeadFilledMace => "Lead Filled Mace", + item_template::MaceTemplate::IronShodQuarterstaff => "Iron Shod Quarterstaff", + item_template::MaceTemplate::OgreMaul => "Ogre Maul", + })) +} + +fn boots_name(item: &model::Item, subtype: item_template::BootsTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::BootsTemplate::SoftLeatherShoes => "Soft Leather Shoes", + item_template::BootsTemplate::SoftLeatherBoots => "Soft Leather Boots", + item_template::BootsTemplate::HardLeatherBoots => "Hard Leather Boots", + item_template::BootsTemplate::Sandals => "Sandals", + item_template::BootsTemplate::ChainBoots => "Chain Boots", + item_template::BootsTemplate::LightPlatedBoots => "Light Plated Boots", + item_template::BootsTemplate::SharkskinBoots => "Sharkskin Boots", + item_template::BootsTemplate::DemonhideBoots => "Demonhide Boots", + item_template::BootsTemplate::WyrmhideBoot => "Wyrmhide Boots", + })) +} + +fn gloves_name(item: &model::Item, subtype: item_template::GlovesTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::GlovesTemplate::LeatherGloves => "Leather Gloves", + item_template::GlovesTemplate::HeavyGloves => "Heavy Gloves", + item_template::GlovesTemplate::ClothGloves => "Cloth Gloves", + item_template::GlovesTemplate::ChainGloves => "Chain Gloves", + item_template::GlovesTemplate::LightGauntlets => "Light Gauntlets", + item_template::GlovesTemplate::HeavyGauntlets => "Heavy Gauntlets", + item_template::GlovesTemplate::SharkskinGloves => "Sharkskin Gloves", + item_template::GlovesTemplate::WarGauntlets => "War Gauntlets", + item_template::GlovesTemplate::DemonhideGloves => "Demonhide Gloves", + item_template::GlovesTemplate::WyrmhideGloves => "Wyrmhide Gloves", + })) +} + +fn cloak_name(item: &model::Item, subtype: item_template::CloakTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::CloakTemplate::LightCloak => "Light Cloak", + item_template::CloakTemplate::HeavyCloak => "Heavy Cloak", + item_template::CloakTemplate::SharkskinCloak => "Sharkskin Cloak", + item_template::CloakTemplate::DemonhideCloak => "Demonhide Cloak", + item_template::CloakTemplate::WyrmhideCloak => "Wyrmhide Cloak", + })) +} +fn helm_name(item: &model::Item, subtype: item_template::HelmTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::HelmTemplate::ClothHat => "Cloth Hat", + item_template::HelmTemplate::SoftLeatherCap => "Soft Leather Cap", + item_template::HelmTemplate::HardLeatherCap => "Hard Leather Cap", + item_template::HelmTemplate::MetalCap => "Metal Cap", + item_template::HelmTemplate::FullHelm => "Full Helm", + item_template::HelmTemplate::GreatHelm => "Great Helm", + item_template::HelmTemplate::WingedHelm => "Winged Helm", + item_template::HelmTemplate::SilverCrown => "Silver Crown", + item_template::HelmTemplate::SilverMask => "Silver Mask", + item_template::HelmTemplate::GoldenCrown => "Golden Crown", + item_template::HelmTemplate::GoldenMask => "Golden Mask", + item_template::HelmTemplate::JewelEncrustedCrown => "Jewel Encrusted Crown", + })) +} + +fn shield_name(item: &model::Item, subtype: item_template::ShieldTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::ShieldTemplate::SmallLeatherShield => "Small Leather Shield", + item_template::ShieldTemplate::MediumLeatherShield => "Medium Leather Shield", + item_template::ShieldTemplate::LargeLeatherShield => "Large Leather Shield", + item_template::ShieldTemplate::Buckler => "Buckler", + item_template::ShieldTemplate::KiteShield => "Kite Shield", + item_template::ShieldTemplate::TowerShield => "Tower Shield", + item_template::ShieldTemplate::SharkskinShield => "Sharkskin Shield", + item_template::ShieldTemplate::DemonhideShield => "Demonhide Shield", + item_template::ShieldTemplate::WyrmhideShield => "Wyrmhide Shield", + })) +} + +fn hard_armor_name(item: &model::Item, subtype: item_template::HardArmorTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::HardArmorTemplate::AugmentedChainMail => "Augmented Chain Mail", + item_template::HardArmorTemplate::BarChainMail => "Bar Chain Mail", + item_template::HardArmorTemplate::BronzePlateMail => "Bronze Plate Mail", + item_template::HardArmorTemplate::ChainMail => "Chain Mail", + item_template::HardArmorTemplate::DoubleChainMail => "Double Chain Mail", + item_template::HardArmorTemplate::FullPlateArmor => "Full Plate Armor", + item_template::HardArmorTemplate::LacqueredPlate => "Lacquered Plate", + item_template::HardArmorTemplate::LaminatedArmor => "Laminated Armor", + item_template::HardArmorTemplate::MetalBrigandineArmor => "Metal Brigandine Armor", + item_template::HardArmorTemplate::MetalLamellarArmor => "Metal Lamellar Armor", + item_template::HardArmorTemplate::MetalScaleMail => "Metal Scale Mail", + item_template::HardArmorTemplate::MithrilChainMail => "Mithril Chain Mail", + item_template::HardArmorTemplate::MithrilPlateArmor => "Mithril Plate Armor", + item_template::HardArmorTemplate::PartialPlateArmor => "Partial Plate Armor", + item_template::HardArmorTemplate::RustyChainMail => "Rusty Chain Mail", + item_template::HardArmorTemplate::StonePlateArmor => "Stone Plate Armor", + })) +} + +fn soft_armor_name(item: &model::Item, subtype: item_template::SoftArmorTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::SoftArmorTemplate::CoolSetOfThreads => "Cool Set of Threads", + item_template::SoftArmorTemplate::DemonhideArmor => "Demonhide Armor", + item_template::SoftArmorTemplate::DuskShroud => "Dusk Shroud", + item_template::SoftArmorTemplate::ElvenChainMail => "Elven Chain Mail", + item_template::SoftArmorTemplate::FilthyNagaHideArmor => "Filthy Naga Hide Armor", + item_template::SoftArmorTemplate::FilthyRags => "Filthy Rags", + item_template::SoftArmorTemplate::HardLeatherArmor => "Hard Leather Armor", + item_template::SoftArmorTemplate::HardLeatherRingMail => "Hard Leather Ring Mail", + item_template::SoftArmorTemplate::HardStuddedLeather => "Hard Studded Leather", + item_template::SoftArmorTemplate::LeatherScaleMail => "Leather Scale Mail", + item_template::SoftArmorTemplate::Robe => "Robe", + item_template::SoftArmorTemplate::SoftLeatherArmor => "Soft Leather Armor", + item_template::SoftArmorTemplate::SoftLeatherRingMail => "Soft Leather Ring Mail", + item_template::SoftArmorTemplate::SoftStuddedLeather => "Soft Studded Armor", + item_template::SoftArmorTemplate::WovenCordArmor => "Woven Cord Armor", + item_template::SoftArmorTemplate::WyrmhideArmor => "Wyrmhide Armor", + item_template::SoftArmorTemplate::LeatherBrigantineArmor => "Leather Brigantine Armor", + })) +} + +fn bracers_name(item: &model::Item, subtype: item_template::BracersTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::BracersTemplate::BracersOfProtection => + if identification::is_item_type_identified(item.item_type(), item.subval) { + "Bracers of Protection" + } else { + "Bracers" + }, + item_template::BracersTemplate::BracersOfDefense => + if identification::is_item_type_identified(item.item_type(), item.subval) { + "Bracers of Defense" + } else { + "Bracers" + }, + item_template::BracersTemplate::BracersOfShielding => + if identification::is_item_type_identified(item.item_type(), item.subval) { + "Bracers of Shielding" + } else { + "Bracers" + }, + item_template::BracersTemplate::MithrilBracers => "Mithril Bracers", + item_template::BracersTemplate::AdamantiteBracers => "Adamantite Bracers", + item_template::BracersTemplate::BracersOfWeaponAttraction => + if identification::is_item_type_identified(item.item_type(), item.subval) { + "Bracers of Weapon Attaction" + } else { + "Bracers" + }, + item_template::BracersTemplate::SilverBraceletOfWarding => + if identification::is_item_type_identified(item.item_type(), item.subval) { + "Silver Bracers of Warding" + } else { + "Silver Bracers" + }, + item_template::BracersTemplate::SilverBracelet => "Silver Bracelet", + item_template::BracersTemplate::GoldBracelet => "Gold Bracelet", + item_template::BracersTemplate::PlatinumBracelet => "Platinum Bracelet", + item_template::BracersTemplate::LeatherBracers => "Leather Bracers", + item_template::BracersTemplate::StuddedLeatherBracers => "Studded Leather Bracers", + item_template::BracersTemplate::LightPlatedBracers => "Light Plated Bracers", + item_template::BracersTemplate::SharkskinBracers => "Sharkskin Bracers", + item_template::BracersTemplate::DemonhideBracers => "Demonhide Bracers", + item_template::BracersTemplate::WyrmhideBracers => "Wyrmhide Bracers", + item_template::BracersTemplate::ChainmailBracers => "Chainmail Bracers", + item_template::BracersTemplate::LamellarBracers => "Lamellar Bracers", + })) +} + +fn belt_name(item: &model::Item, subtype: item_template::BeltTemplate) -> String { + generate_armor_name(item, Cow::from(match subtype { + item_template::BeltTemplate::Sash => "Sash", + item_template::BeltTemplate::LightBelt => "Light Belt", + item_template::BeltTemplate::Belt => "Belt", + item_template::BeltTemplate::HeavyBelt => "Heavy Belt", + item_template::BeltTemplate::LightPlatedBelt => "Light Plated Belt", + item_template::BeltTemplate::SharkskinBelt => "Sharkskin Belt", + item_template::BeltTemplate::DemonhideBelt => "Demonhide Belt", + item_template::BeltTemplate::WyrmhideBelt => "Wyrmhide Belt", + })) +} + +fn amulet_name(item: &model::Item, subtype: item_template::AmuletTemplate) -> String { + let mut parts = Vec::new(); + parts.push(Cow::from("Amulet")); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(match subtype { + item_template::AmuletTemplate::AmuletOfAdornment1 => Cow::from(" of Adornment"), + item_template::AmuletTemplate::AmuletOfAdornment2 => Cow::from(" of Adornment"), + item_template::AmuletTemplate::AmuletOfWisdom => Cow::from(" of Wisdom"), + item_template::AmuletTemplate::AmuletOfCharisma => Cow::from(" of Charisma"), + item_template::AmuletTemplate::AmuletOfSearching => Cow::from(" of Searching"), + item_template::AmuletTemplate::AmuletOfTeleportation => Cow::from(" of Teleportation"), + item_template::AmuletTemplate::AmuletOfSlowDigestion => Cow::from(" of Slow Digestion"), + item_template::AmuletTemplate::AmuletOfResistAcid => Cow::from(" of Resist Acid"), + item_template::AmuletTemplate::AmuletOfTheMagi => Cow::from(" of the Magi"), + item_template::AmuletTemplate::AmuletOfDoom => Cow::from(" of Doom"), + item_template::AmuletTemplate::SilverNecklace => + Cow::from(format!("{} (Silver)", helpers::plural_s(&item))), + item_template::AmuletTemplate::GoldNecklace => + Cow::from(format!("{} (Gold)", helpers::plural_s(&item))), + item_template::AmuletTemplate::MithrilNecklace => + Cow::from(format!("{} (Mithril)", helpers::plural_s(&item))), + }); + } + if item.p1 != 0 { + parts.push(helpers::p1(&item)); + } + if item.tohit != 0 { + parts.push(helpers::to_hit(&item)); + } + if item.todam != 0 { + parts.push(helpers::to_damage(&item)); + } + if item.toac != 0 { + parts.push(helpers::to_ac(&item)); + } + parts.join("") +} + +fn ring_name(item: &model::Item, subtype: item_template::RingTemplate) -> String { + let mut parts = Vec::new(); + parts.push(Cow::from("Ring")); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::RingTemplate::RingOfGainStrength => " of Gain Strength", + item_template::RingTemplate::RingOfGainDexterity => " of Gain Dexterity", + item_template::RingTemplate::RingOfGainConstitution => " of Gain Constitution", + item_template::RingTemplate::RingOfGainIntelligence => " of Gain Intelligence", + item_template::RingTemplate::RingOfSpeed1 => " of Speed", + item_template::RingTemplate::RingOfSpeed2 => " of Speed", + item_template::RingTemplate::RingOfSearching => " of Searching", + item_template::RingTemplate::RingOfTeleportation => " of Teleportation", + item_template::RingTemplate::RingOfSlowDigestion => " of Slow Digestion", + item_template::RingTemplate::RingOfResistFire => " of Resist Fire", + item_template::RingTemplate::RingOfResistCold => " of Resist Cold", + item_template::RingTemplate::RingOfFeatherFalling => " of Feather Falling", + item_template::RingTemplate::RingOfAdornment1 => " of Adornment", + item_template::RingTemplate::RingOfAdornment2 => " of Adornment", + item_template::RingTemplate::RingOfWeakness => " of Weakness", + item_template::RingTemplate::RingOfLordlyProtectionFire => " of Lordly Protection (Fire)", + item_template::RingTemplate::RingOfLordlyProtectionAcid => " of Lordly Protection (Acid)", + item_template::RingTemplate::RingOfLordlyProtectionCold => " of Lordly Protection (Cold)", + item_template::RingTemplate::RingOfWoe => " of Woe", + item_template::RingTemplate::RingOfStupidity => " of Stupidity", + item_template::RingTemplate::RingOfIncreaseDamage => " of Increase Damage", + item_template::RingTemplate::RingOfIncreaseToHit => " of Increase To-hit", + item_template::RingTemplate::RingOfProtection => " of Protection", + item_template::RingTemplate::RingOfAggravateMonsters => " of Aggravate Monster", + item_template::RingTemplate::RingOfSeeInvisible => " of See Invisible", + item_template::RingTemplate::RingOfSustainStrength => " of Sustain Strength", + item_template::RingTemplate::RingOfSustainIntelligence => " of Sustain Intelligence", + item_template::RingTemplate::RingOfSustainWisdom => " of Sustain Wisdom", + item_template::RingTemplate::RingOfSustainConstitution => " of Sustain Constitution", + item_template::RingTemplate::RingOfSustainDexterity => " of Sustain Dexterity", + item_template::RingTemplate::RingOfSustainCharisma => " of Sustain Charisma", + item_template::RingTemplate::RingOfSlaying => " of Slaying", + item_template::RingTemplate::RingOfGnomekind => " of Gnomekind", + })); + } + if item.p1 != 0 { + parts.push(helpers::p1(&item)); + } + if item.tohit != 0 { + parts.push(helpers::to_hit(&item)); + } + if item.todam != 0 { + parts.push(helpers::to_damage(&item)); + } + if item.toac != 0 { + parts.push(helpers::to_ac(&item)); + } + parts.join("") +} + +fn staff_name(item: &model::Item, subtype: item_template::StaffTemplate) -> String { + let mut parts = Vec::new(); + parts.push(Cow::from("Staff")); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::StaffTemplate::StaffOfLight => " of Light", + item_template::StaffTemplate::StaffOfDoorStairLocation => " of Door/Stair Location", + item_template::StaffTemplate::StaffOfTrapLocation => "of Trap Location", + item_template::StaffTemplate::StaffOfTreasureLocation => " of Treasure Location", + item_template::StaffTemplate::StaffOfObjectLocation => " of Object Location", + item_template::StaffTemplate::StaffOfTeleportation => " of Teleportation", + item_template::StaffTemplate::StaffOfEarthquakes => " of Earthquakes", + item_template::StaffTemplate::StaffOfSummoning => " of Summoning", + item_template::StaffTemplate::StaffOfDestruction => " of *Destruction*", + item_template::StaffTemplate::StaffOfStarlite => " of Starlite", + item_template::StaffTemplate::StaffOfHasteMonsters => " of Haste Monsters", + item_template::StaffTemplate::StaffOfSlowMonsters => " of Slow Monsters", + item_template::StaffTemplate::StaffOfSleepMonsters => " of Sleep Monsters", + item_template::StaffTemplate::StaffOfCureLightWounds => " of Cure Light Wounds", + item_template::StaffTemplate::StaffOfDetectInvisible => " of Detect Invisible", + item_template::StaffTemplate::StaffOfSpeed => " of Speed", + item_template::StaffTemplate::StaffOfSlowness => " of Slowness", + item_template::StaffTemplate::StaffOfMassPolymorph => " of Mass Polymorph", + item_template::StaffTemplate::StaffOfRemoveCurse => " of Remove Curse", + item_template::StaffTemplate::StaffOfDetectEvil => " of Detect Evil", + item_template::StaffTemplate::StaffOfCuring => " of Curing", + item_template::StaffTemplate::StaffOfDispelEvil => " of Dispel Evil", + item_template::StaffTemplate::StaffOfDarkness => " of Darkness", + item_template::StaffTemplate::StaffOfIdentify => " of Identify", + })); + } + parts.push(helpers::charges(&item)); + parts.join("") +} + +fn wand_name(item: &model::Item, subtype: item_template::WandTemplate) -> String { + let mut parts = Vec::new(); + parts.push(Cow::from("Wand")); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push( + Cow::from(match subtype { + item_template::WandTemplate::WandOfProbing => " of Probing", + item_template::WandTemplate::WandOfLight => " of Light", + item_template::WandTemplate::WandOfLightningBolts => "of Lightning Bolts", + item_template::WandTemplate::WandOfFrostBolts => " of Frost Bolts", + item_template::WandTemplate::WandOfFireBolts => " of Fire Bolts", + item_template::WandTemplate::WandOfStoneToMud => " of Stone-to-Mud", + item_template::WandTemplate::WandOfPolymorph => " of Polymorph", + item_template::WandTemplate::WandOfHealMonster => " of Heal Monster", + item_template::WandTemplate::WandOfHasteMonster => " of Haste Monster", + item_template::WandTemplate::WandOfSlowMonster => " of Slow Monster", + item_template::WandTemplate::WandOfConfuseMonster => " of Confuse Monster", + item_template::WandTemplate::WandOfSleepMonster => " of Sleep Monster", + item_template::WandTemplate::WandOfDrainLife => " of Drain Life", + item_template::WandTemplate::WandOfTrapDoorDestruction => " of Trap/Door destruction", + item_template::WandTemplate::WandOfMagicMissile => " of Magic Missile", + item_template::WandTemplate::WandOfWallBuilding => " of Wall Building", + item_template::WandTemplate::WandOfCloneMonster => " of Clone Monster", + item_template::WandTemplate::WandOfTeleportAway => " of Teleport Away", + item_template::WandTemplate::WandOfDisarming => " of Disarming", + item_template::WandTemplate::WandOfLightningBalls => " of Lightning Balls", + item_template::WandTemplate::WandOfColdBalls => " of Cold Balls", + item_template::WandTemplate::WandOfFireBalls => " of Fire Balls", + item_template::WandTemplate::WandOfStinkingCloud => " of Stinking Cloud", + item_template::WandTemplate::WandOfAcidBalls => " of Acid Balls", + item_template::WandTemplate::WandOfWonder => " of Wonder", + })); + } + parts.push(helpers::charges(&item)); + parts.join("") +} + +fn scroll_name(item: &model::Item, subtype: item_template::ScrollTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(&item)); + parts.push(Cow::from(if item.number == 1 { "Scroll" } else { "Scrolls" })); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::ScrollTemplate::AggravateMonster => " of Trap/Door Destruction", + item_template::ScrollTemplate::Blessing => " of Blessing", + item_template::ScrollTemplate::CreateFood => " of Create Food", + item_template::ScrollTemplate::CurseArmor => " of Curse Armor", + item_template::ScrollTemplate::CurseWeapon => " of Curse Weapon", + item_template::ScrollTemplate::Darkness => " of Darkness", + item_template::ScrollTemplate::Destruction => " of Destruction", + item_template::ScrollTemplate::DetectInvisible => " of Detect Invisible", + item_template::ScrollTemplate::DispelUndead => " of Dispel Undead", + item_template::ScrollTemplate::DoorCreation => " of Door Creation", + item_template::ScrollTemplate::DoorStairLocation => " of Door/Stair Location", + item_template::ScrollTemplate::EnchantArmor => " of Enchant Armor", + item_template::ScrollTemplate::EnchantWeapon => " of Enchant Weapon", + item_template::ScrollTemplate::EnchantWeaponToDam => " of Enchant Weapon To Dam", + item_template::ScrollTemplate::EnchantWeaponToHit => " of Enchant Weapon To Hit", + item_template::ScrollTemplate::FeignDeath => " of Feign Death", + item_template::ScrollTemplate::Genocide => " of Genocide", + item_template::ScrollTemplate::HolyChant => " of Holy Chant", + item_template::ScrollTemplate::HolyPrayer => " of Holy Prayer", + item_template::ScrollTemplate::Identify => " of Identify", + item_template::ScrollTemplate::Light => " of Light", + item_template::ScrollTemplate::MagicMapping => " of Magic Mapping", + item_template::ScrollTemplate::MakeMunchies => " of Make Munchies", + item_template::ScrollTemplate::MassGenocide => " of Mass Genocide", + item_template::ScrollTemplate::MonsterConfusion => " of Monster Confusion", + item_template::ScrollTemplate::ObjectDetection => " of Object Detection", + item_template::ScrollTemplate::PhaseDoor => " of Phase Door", + item_template::ScrollTemplate::ProtectionFromEvil => " of Protection from Evil", + item_template::ScrollTemplate::Recharging => " of Recharging", + item_template::ScrollTemplate::RemoveCurse => " of Remove Curse", + item_template::ScrollTemplate::RuneOfProtection => " of Rune of Protection", + item_template::ScrollTemplate::SleepMonster => " of Sleep Monster", + item_template::ScrollTemplate::SummonMonster => " of Summon Monster", + item_template::ScrollTemplate::SummonUndead => " of Summon Undead", + item_template::ScrollTemplate::Teleport => " of Teleport", + item_template::ScrollTemplate::TeleportLevel => " of Teleport Level", + item_template::ScrollTemplate::TrapCreation => " of Trap Creation", + item_template::ScrollTemplate::TrapDetection => " of Trap Detection", + item_template::ScrollTemplate::TrapDoorDestruction => " of Trap/Door Destruction", + item_template::ScrollTemplate::TreasureDetection => " of Treasure Detection", + item_template::ScrollTemplate::Wishing => " of Wishing", + item_template::ScrollTemplate::WordOfRecall => " of Word of Recall", + })); + } + parts.join("") +} + +fn potion_name(item: &model::Item, subtype: item_template::PotionTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(Cow::from(if item.number == 1 { "Potion" } else { "Potions" })); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::PotionTemplate::AppleJuice => " of Apple Juice", + item_template::PotionTemplate::Blindness => " of Blindness", + item_template::PotionTemplate::Boldliness => " of Boldliness", + item_template::PotionTemplate::Charisma => " of Charisma", + item_template::PotionTemplate::Confusion => " of Confusion", + item_template::PotionTemplate::CureCriticalWounds => " of Cure Critical Wounds", + item_template::PotionTemplate::CureLightWounds => " of Cure Light Wounds", + item_template::PotionTemplate::CureSeriousWounds => " of Cure Serious Wounds", + item_template::PotionTemplate::DetectInvisible => " of Detect Invisible", + item_template::PotionTemplate::FleaBile => " of Flea Bile", + item_template::PotionTemplate::GainConstitution => " of Gain Constitution", + item_template::PotionTemplate::GainDexterity => " of Gain Dexterity", + item_template::PotionTemplate::GainExperience => " of Gain Experience", + item_template::PotionTemplate::GainIntelligence => " of Restore Strength", + item_template::PotionTemplate::GainStrength => " of Gain Strength", + item_template::PotionTemplate::GainWisdom => " of Gain Wisdom", + item_template::PotionTemplate::HasteSelf => " of Haste Self", + item_template::PotionTemplate::Healing => " of Healing", + item_template::PotionTemplate::Heroism => " of Heroism", + item_template::PotionTemplate::InfraVision => " of Infra-Vision", + item_template::PotionTemplate::Invulnerability => " of Invulnerability", + item_template::PotionTemplate::Learning => " of Learning", + item_template::PotionTemplate::LoseIntelligence => " of Lose Intelligence", + item_template::PotionTemplate::LoseMemories => " of Lose Memories", + item_template::PotionTemplate::LoseWisdom => " of Lose Wisdom", + item_template::PotionTemplate::NeutralizePoison => " of Neutralize Poison", + item_template::PotionTemplate::Poison => " of Poison", + item_template::PotionTemplate::ResistCold => " of Resist Cold", + item_template::PotionTemplate::ResistHeat => " of Resist Heat", + item_template::PotionTemplate::RestoreCharisma => " of Restore Charisma", + item_template::PotionTemplate::RestoreConstitution => " of Restore Consitution", + item_template::PotionTemplate::RestoreDexterity => " of Restore Dexterity", + item_template::PotionTemplate::RestoreIntelligence => " of Restore Intelligence", + item_template::PotionTemplate::RestoreLifeLevels => " of Restore Life Levels", + item_template::PotionTemplate::RestoreMana => " of Restore Mana", + item_template::PotionTemplate::RestoreStrength => " of Restore Strength", + item_template::PotionTemplate::RestoreWisdom => " of Restore Wisdom", + item_template::PotionTemplate::SaltWater => " of Salt Water", + item_template::PotionTemplate::Sleep => " of Sleep", + item_template::PotionTemplate::SlimeMoldJuice => " of Slime Mold Juice", + item_template::PotionTemplate::SlowPoison => " of Slow Poison", + item_template::PotionTemplate::Slowness => " of Slowness", + item_template::PotionTemplate::SuperHeroism => " of Super Heroism", + item_template::PotionTemplate::Ugliness => " of Ugliness", + item_template::PotionTemplate::Water => " of Water", + })) + } + parts.join("") +} + +fn food_name(item: &model::Item, subtype: item_template::FoodTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(Cow::from(match subtype { + item_template::FoodTemplate::Mushroom | + item_template::FoodTemplate::Mushroom2 | + item_template::FoodTemplate::MushroomOfPoison | + item_template::FoodTemplate::MushroomOfBlindness | + item_template::FoodTemplate::MushroomOfParanoia | + item_template::FoodTemplate::MushroomOfConfusion | + item_template::FoodTemplate::MushroomOfHallucination | + item_template::FoodTemplate::MushroomOfCurePoison | + item_template::FoodTemplate::MushroomOfCureBlindness | + item_template::FoodTemplate::MushroomOfCureParanoia | + item_template::FoodTemplate::MushroomOfCureConfusion | + item_template::FoodTemplate::MushroomOfWeakness | + item_template::FoodTemplate::MushroomOfUnhealth | + item_template::FoodTemplate::MushroomOfRestoreConstitution | + item_template::FoodTemplate::MushroomOfFirstAid | + item_template::FoodTemplate::MushroomOfMinorCures | + item_template::FoodTemplate::MushroomOfLightCures | + item_template::FoodTemplate::MushroomOfRestoring | + item_template::FoodTemplate::MushroomOfPoison2 | + item_template::FoodTemplate::MushroomOfHallucination2 | + item_template::FoodTemplate::MushroomOfCurePoison2 | + item_template::FoodTemplate::MushroomOfUnhealth2 | + item_template::FoodTemplate::MushroomOfCureSeriousWounds + => format!("Mushroom{}", helpers::plural_s(&item)), + item_template::FoodTemplate::PintOfFineGradeMush + => format!("Pint{} of Fine Grade Mush", helpers::plural_s(&item)), + item_template::FoodTemplate::RationOfFood + => format!("Ration{} of Food", helpers::plural_s(&item)), + item_template::FoodTemplate::HardBiscuit + => format!("Hard Biscuit{}", helpers::plural_s(&item)), + item_template::FoodTemplate::BeefJerky + => format!("Strip{} of Beef Jerky", helpers::plural_s(&item)), + item_template::FoodTemplate::FineAle + => format!("Pint{} of Fine Ale", helpers::plural_s(&item)), + item_template::FoodTemplate::FineWine + => format!("Pint{} of Fine Wine", helpers::plural_s(&item)), + item_template::FoodTemplate::ElvishWaybread + => format!("Piece{} of Elvish Waybread", helpers::plural_s(&item)), + item_template::FoodTemplate::Stew + => format!("Stew{}", helpers::plural_s(&item)), + item_template::FoodTemplate::GreenJelly + => format!("Green Jelly{}", helpers::plural_s(&item)), + item_template::FoodTemplate::BerriesPoisonous | + item_template::FoodTemplate::BerriesSmurfberries | + item_template::FoodTemplate::BerriesGoodberries + => format!("Handful{} of Berries", helpers::plural_s(&item)), + item_template::FoodTemplate::EyeballOfNed + => format!("Eyeball{}", helpers::plural_s(&item)), + })); + + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::FoodTemplate::MushroomOfPoison => " of Poison", + item_template::FoodTemplate::MushroomOfBlindness => " of Blindness", + item_template::FoodTemplate::MushroomOfParanoia => " of Paranoia", + item_template::FoodTemplate::MushroomOfConfusion => " of Confusion", + item_template::FoodTemplate::MushroomOfHallucination => " of Hallucination", + item_template::FoodTemplate::MushroomOfCurePoison => " of Cure Poison", + item_template::FoodTemplate::MushroomOfCureBlindness => " of Cure Blindness", + item_template::FoodTemplate::MushroomOfCureParanoia => " of Cure Paranoia", + item_template::FoodTemplate::MushroomOfCureConfusion => " of Cure Confusion", + item_template::FoodTemplate::MushroomOfWeakness => " of Weakness", + item_template::FoodTemplate::MushroomOfUnhealth => " of Unhealth", + item_template::FoodTemplate::MushroomOfRestoreConstitution => " of Restore Constitution", + item_template::FoodTemplate::MushroomOfFirstAid => " of First-Aid", + item_template::FoodTemplate::MushroomOfMinorCures => " of Minor Cures", + item_template::FoodTemplate::MushroomOfLightCures => " of Light Cures", + item_template::FoodTemplate::MushroomOfRestoring => " of Restoring", + item_template::FoodTemplate::MushroomOfPoison2 => " of Poison", + item_template::FoodTemplate::MushroomOfHallucination2 => " of Hallucination", + item_template::FoodTemplate::MushroomOfCurePoison2 => " of Cure Poison", + item_template::FoodTemplate::MushroomOfUnhealth2 => " of Unhealth", + item_template::FoodTemplate::MushroomOfCureSeriousWounds => " of Cure Serious Wounds", + item_template::FoodTemplate::BerriesPoisonous => " (Poisonous)", + item_template::FoodTemplate::BerriesSmurfberries => " (Smurfberries)", + item_template::FoodTemplate::BerriesGoodberries => " (Goodberries)", + item_template::FoodTemplate::EyeballOfNed => " of Ned", + _ => "", + })); + } + parts.join("") +} + +fn junk_food_name(item: &model::Item, subtype: item_template::JunkFoodTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(Cow::from(match subtype { + item_template::JunkFoodTemplate::BoxOfPiranhaCrackers => + format!("Box{} of Piranha Crackers", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::CanOfOrcaCola => + format!("Can{} of Orca-Cola", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::TwelvePoundTrollBuger => + format!("Twelve-Pound Troll Burger{}", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::BagOfBrontosaurusChips => + format!("Bag{} of Brontosaurus Chips", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::SliceOfPurpleMushroomPizza => + format!("Slice{} of Purple Mushroom Pizza", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::PeanutButterAndGrapeJellySandwich => + format!("Peanut Butter and Grape Jelly Sandwich{}", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::DragonSteak => + format!("Dragon Steak{}", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::VorpalBunnyThroatLozenge => + format!("Vorpal Bunny Throat Lozenge{}", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::DeepFriedGiantCentipede => + format!("Deep-Fried Giant Centipede{}", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::PintOfBeetleJuice => + format!("Pint{} of Beetle Juice", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::BownOfBatStew => + format!("Bowl{} of Bat Stew", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::JarOfPickledLeeches => + format!("Jar{} of Pickled Leeches", helpers::plural_s(&item)), + item_template::JunkFoodTemplate::PackOfKittenMcNuggets => + format!("Pack{} of Kitten McNuggets", helpers::plural_s(&item)), + })); + parts.join("") +} + +fn chime_name(item: &model::Item, subtype: item_template::ChimeTemplate) -> String { + let mut parts = Vec::new(); + parts.push(Cow::from("Chime")); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::ChimeTemplate::ChimeOfLight => " of Light", + item_template::ChimeTemplate::ChimeOfDetectDoorsStairs => " of Detect Doors/Stairs", + item_template::ChimeTemplate::ChimeOfDetectTraps => " of Detect Traps", + item_template::ChimeTemplate::ChimeOfTeleportation => " of Teleportation", + item_template::ChimeTemplate::ChimeOfThunderblast => " of Thunderblasts", + item_template::ChimeTemplate::ChimeOfSummonMonster => " of Summon Monster", + item_template::ChimeTemplate::ChimeOfDisarming => " of Disarming", + item_template::ChimeTemplate::ChimeOfAggravation => " of Aggravation", + item_template::ChimeTemplate::ChimeOfSlowMonster => " of Slow Monster", + item_template::ChimeTemplate::ChimeOfSootheMonster => " of Soothe Monster", + item_template::ChimeTemplate::ChimeOfCureLightWound => " of Cure Light Wound", + item_template::ChimeTemplate::ChimeOfChanging => " of Changing", + item_template::ChimeTemplate::ChimeOfRemoveCurse => " of Remove Curse", + item_template::ChimeTemplate::ChimeOfCuring => " of Curing", + item_template::ChimeTemplate::ChimeOfDispelEvil => " of Dispel Evil", + item_template::ChimeTemplate::ChimeOfDarkness => " of Darkness", + })); + } + parts.push(helpers::charges(&item)); + parts.join("") +} + +fn horn_name(item: &model::Item, subtype: item_template::HornTemplate) -> String { + let mut parts = Vec::new(); + parts.push(Cow::from("Horn")); + if identification::is_item_type_identified(item.item_type(), item.subval) { + parts.push(Cow::from(match subtype { + item_template::HornTemplate::HornOfBubbles => " of Bubbles", + item_template::HornTemplate::HornOfCalling => " of Calling", + item_template::HornTemplate::HornOfSoftSounds => " of Soft Sounds", + item_template::HornTemplate::HornOfBlasting => " of *Blasting*", + item_template::HornTemplate::HornOfCold => " of Cold", + item_template::HornTemplate::HornOfHeat => " of Heat", + item_template::HornTemplate::HornOfGas => " of Gas", + item_template::HornTemplate::HornOfRecall => " of Recall", + item_template::HornTemplate::HornOfChaos => " of *Chaos*", + item_template::HornTemplate::HornOfGlue => " of Glue", + item_template::HornTemplate::HornOfValhalla => " of Valhalla", + item_template::HornTemplate::HornOfTritons => " of Tritons", + item_template::HornTemplate::HornOfFog => " of Fog", + })); + } + if item.is_identified() { + parts.push(helpers::charges(item)) + } + parts.join("") +} + +fn magic_book_name(item: &model::Item, subtype: item_template::MagicBookTemplate) -> String { + generate_book_name(item, Cow::from(match subtype { + item_template::MagicBookTemplate::BeginnersMagic => "Book of Magic Spells [Beginners-Magik]", + item_template::MagicBookTemplate::Magic1 => "Book of Magic Spells [Magik I]", + item_template::MagicBookTemplate::Magic2 => "Book of Magic Spells [Magik II]", + item_template::MagicBookTemplate::MagesGuideToPower => "Book of Magic Spells [The Mages Guide to Power]", + })) +} + +fn prayer_book_name(item: &model::Item, subtype: item_template::PrayerBookTemplate) -> String { + generate_book_name(item, Cow::from(match subtype { + item_template::PrayerBookTemplate::BeginnersHandbook => "Holy Book of Prayers [Beginners Handbook]", + item_template::PrayerBookTemplate::WordsOfWisdom => "Holy Book of Prayers [Words of Wisdom]", + item_template::PrayerBookTemplate::ChantsAndBlessings => "Holy Book of Prayers [Chants and Blessings]", + item_template::PrayerBookTemplate::ExorcismAndDispelling => "Holy Book of Prayers [Exorcism and Dispelling]", + })) +} + +fn instrument_name(item: &model::Item, subtype: item_template::InstrumentTemplate) -> String { + let mut parts = Vec::new(); + parts.push(helpers::number_of(item)); + parts.push(Cow::from(match subtype { + item_template::InstrumentTemplate::PipesOfPeace => "Pipes of Peace", + item_template::InstrumentTemplate::LyreOfNature => "Lyre of Nature", + item_template::InstrumentTemplate::LuteOfTheWoods => "Lute of the Woods", + item_template::InstrumentTemplate::HarpOfTheDruids =>"Harp of the Druids" , + })); + parts.join("") +} + +fn song_book_name(item: &model::Item, subtype: item_template::SongBookTemplate) -> String { + generate_book_name(item, Cow::from(match subtype { + item_template::SongBookTemplate::BeginnersHandbook => "Book of Bard Lyrics [Beginners Handbook]", + item_template::SongBookTemplate::SongBook1 => "Songs of Charming [Song Book I]", + item_template::SongBookTemplate::SongBook2 => "Ballads of Knowledge [Song Book II]", + item_template::SongBookTemplate::GreaterSongBook => "Epics of the Bards [Greater Song Book]", + })) +} + +fn lodging_at_inn_name(item: &model::Item, subtype: item_template::LodgingAtInnTemplate) -> String { + match subtype { + item_template::LodgingAtInnTemplate::LodgingForOneDay => "Lodging for one day", + item_template::LodgingAtInnTemplate::LodgingForThreeDays => "Lodging for three days", + item_template::LodgingAtInnTemplate::LodgingForOneWeek => "Lodging for the week", + item_template::LodgingAtInnTemplate::RoomAndBoardForOneDay => "Room and board for one day", + }.to_string() +} + +fn dungeon_feature_name(item: &model::Item, subtype: item_template::DungeonFeatureTemplate) -> String { + let mut parts = Vec::new(); + match subtype { + item_template::DungeonFeatureTemplate::Money => { + parts.push(helpers::number_of(item)); + Cow::from(match item.subval { + 1 => format!(" iron piece{}", helpers::plural_s(&item)), + 2 => format!(" copper piece{}", helpers::plural_s(&item)), + 3 => format!(" iron piece{}", helpers::plural_s(&item)), + 4 => format!(" copper piece{}", helpers::plural_s(&item)), + 5 => format!(" silver piece{}", helpers::plural_s(&item)), + 6 => format!(" copper piece{}", helpers::plural_s(&item)), + 7 => format!(" silver piece{}", helpers::plural_s(&item)), + 12 => format!(" gold piece{}", helpers::plural_s(&item)), + 16 => format!(" silver piece{}", helpers::plural_s(&item)), + 18 => format!(" gold piece{}", helpers::plural_s(&item)), + 20 => format!(" platinum piece{}", helpers::plural_s(&item)), + 24 => format!(" gold piece{}", helpers::plural_s(&item)), + 28 => format!(" platinum piece{}", helpers::plural_s(&item)), + 32 => format!(" mithril piece{}", helpers::plural_s(&item)), + 50 => format!(" gold piece{}", helpers::plural_s(&item)), + 55 => format!(" platinum piece{}", helpers::plural_s(&item)), + 60 => format!(" mithril piece{}", helpers::plural_s(&item)), + }) + }, + item_template::DungeonFeatureTemplate::UnseenTrap | + item_template::DungeonFeatureTemplate::SeenTrap => Cow::from(match item.subval { + 1 => "an open pit", + 2 => "an arrow trap", + 3 => "a covered pit", + 4 => "a trap door", + 5 => "a gas trap", + 6 => "a loose rock", + 7 => "a dart trap", + 8 => "a strange rune", + 9 => "some loose rock", + 10 => "a gas trap", + 11 => "a strange rune", + 12 => "a blackened spot", + 13 => "some corroded rock", + 14 => "a gas trap", + 15 => "a gas trap", + 16 => "a gas trap", + 17 => "a dart trap", + 18 => "a dart trap", + 20 => "a chute", + _ => "an unnamed trap ", + }), + item_template::DungeonFeatureTemplate::Rubble => Cow::from("some rubble"), + item_template::DungeonFeatureTemplate::OpenDoor => Cow::from("an open door"), + item_template::DungeonFeatureTemplate::ClosedDoor => Cow::from("a closed door"), + item_template::DungeonFeatureTemplate::UpStaircase => Cow::from("an up staircase"), + item_template::DungeonFeatureTemplate::DownStaircase => Cow::from("a down staircase"), + item_template::DungeonFeatureTemplate::SecretDoor => Cow::from("a secret door"), + item_template::DungeonFeatureTemplate::EntranceToStore => Cow::from(match item.subval { + 101 => "the entrance to the General Store", + 102 => "the entrance to the Armory", + 103 => "the entrance to the Weapon Smiths", + 104 => "the entrance to the Temple", + 105 => "the entrance to the Alchemy Shop", + 106 => "the entrance to the Magic Shop", + 107 => "the entrance to the Inn", + 108 => "the entrance to the Trading Post", + 109 => "the entrance to the Library", + 110 => "the entrance to the Music Shop", + 111 => "the entrance to the Insurance Shop", + 112 => "the entrance to the Bank", + 113 => "the entrance to the Gem Store", + 114 => "the entrance to the Money Exchange", + 115 => "the entrance to the Casino", + 116 => "the entrance to the All-Nite Deli", + 117 => "the entrance to a strange building", + 118 => "the entrance to a building", + 120 => "the entrance to a building", + 121 => "the entrance to a building", + 122 => "the entrance to a building", + 123 => "the entrance to a building", + 124 => "the entrance to a building", + }), + item_template::DungeonFeatureTemplate::UpSteepStaircase => Cow::from("a steep staircase"), + item_template::DungeonFeatureTemplate::DownSteepStaircase => Cow::from("a steep staircase"), + item_template::DungeonFeatureTemplate::Whirlpool => Cow::from("a whirlpool"), + }; + parts.join("") +} + + +pub fn generate(item: &model::Item) -> String { + match item.item_type() { + model::ItemType::MiscObject(subtype) => misc_object_name(&item, subtype), + model::ItemType::Chest(subtype) => chest_name(&item, subtype), + model::ItemType::MiscUsable(subtype) => misc_name(&item, subtype), + model::ItemType::Spike(subtype) => misc_name(&item, subtype), + model::ItemType::FlaskOfOil(subtype) => misc_name(&item, subtype), + model::ItemType::Jewelry(subtype) => jewelry_name(&item, subtype), + model::ItemType::Bag(subtype) => bag_name(&item, subtype), + model::ItemType::Gem(subtype) => gem_name(&item, subtype), + model::ItemType::WearableGem(subtype) => wearable_gem_name(&item, subtype), + model::ItemType::SlingAmmo(subtype) => ammo_name(&item, subtype), + model::ItemType::Bolt(subtype) => ammo_name(&item, subtype), + model::ItemType::Arrow(subtype) => ammo_name(&item, subtype), + model::ItemType::LightSource(subtype) => light_source_name(&item, subtype), + model::ItemType::Bow(subtype) => bow_name(&item, subtype), + model::ItemType::Crossbow(subtype) => crossbow_name(&item, subtype), + model::ItemType::Sling(subtype) => sling_name(&item, subtype), + model::ItemType::Axe(subtype) => axe_name(&item, subtype), + model::ItemType::Polearm(subtype) => polearm_name(&item, subtype), + model::ItemType::Dagger(subtype) => dagger_name(&item, subtype), + model::ItemType::Sword(subtype) => sword_name(&item, subtype), + model::ItemType::Pick(subtype) => pick_name(&item, subtype), + model::ItemType::Mace(subtype) => mace_name(&item, subtype), + model::ItemType::Boots(subtype) => boots_name(&item, subtype), + model::ItemType::Gloves(subtype) => gloves_name(&item, subtype), + model::ItemType::Cloak(subtype) => cloak_name(&item, subtype), + model::ItemType::Helm(subtype) => helm_name(&item, subtype), + model::ItemType::Shield(subtype) => shield_name(&item, subtype), + model::ItemType::HardArmor(subtype) => hard_armor_name(&item, subtype), + model::ItemType::SoftArmor(subtype) => soft_armor_name(&item, subtype), + model::ItemType::Bracers(subtype) => bracers_name(&item, subtype), + model::ItemType::Belt(subtype) => belt_name(&item, subtype), + model::ItemType::Amulet(subtype) => amulet_name(&item, subtype), + model::ItemType::Ring(subtype) => ring_name(&item, subtype), + model::ItemType::Staff(subtype) => staff_name(&item, subtype), + model::ItemType::Wand(subtype) => wand_name(&item, subtype), + model::ItemType::Scroll(subtype) => scroll_name(&item, subtype), + model::ItemType::Potion(subtype) => potion_name(&item, subtype), + model::ItemType::Food(subtype) => food_name(&item, subtype), + model::ItemType::JunkFood(subtype) => junk_food_name(&item, subtype), + model::ItemType::Chime(subtype) => chime_name(&item, subtype), + model::ItemType::Horn(subtype) => horn_name(&item, subtype), + model::ItemType::MagicBook(subtype) => magic_book_name(&item, subtype), + model::ItemType::PrayerBook(subtype) => prayer_book_name(&item, subtype), + model::ItemType::Instrument(subtype) => instrument_name(&item, subtype), + model::ItemType::SongBook(subtype) => song_book_name(&item, subtype), + model::ItemType::LodgingAtInn(subtype) => lodging_at_inn_name(&item, subtype), + model::ItemType::Money(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::UnseenTrap(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::SeenTrap(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::Rubble(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::OpenDoor(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::ClosedDoor(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::UpStaircase(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::DownStaircase(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::SecretDoor(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::EntranceToStore(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::UpSteepStaircase(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::DownSteepStaircase(subtype) => dungeon_feature_name(&item, subtype), + model::ItemType::Whirlpool(subtype) => dungeon_feature_name(&item, subtype), + } +} diff --git a/src/logic/item_name/item_name_interop.rs b/src/logic/item_name/item_name_interop.rs new file mode 100644 index 00000000..5e9deaa9 --- /dev/null +++ b/src/logic/item_name/item_name_interop.rs @@ -0,0 +1,20 @@ +use logic::item_name; +use debug; +use model; + +use libc; + +#[no_mangle] +pub extern fn C_item_name_generate_name(item_ptr: *const model::Item, result: [libc::c_char; 70]) { + debug::enter(&format!("C_item_name_generate_name")); + + let item = unsafe { *item_ptr }; + let item_name = item_name::generate(&item); + result = [0; 70]; + for (index, c) in item_name.chars().take(70 - 1).enumerate() { + result[index] = c as libc::c_char; + } + + debug::leave("C_item_name_generate_name"); +} + diff --git a/src/logic/item_name/mod.rs b/src/logic/item_name/mod.rs new file mode 100644 index 00000000..7dee7bb4 --- /dev/null +++ b/src/logic/item_name/mod.rs @@ -0,0 +1,5 @@ +pub use self::item_name::generate; + +mod helpers; +mod item_name; +mod item_name_interop; diff --git a/src/logic/item_symbol.rs b/src/logic/item_symbol.rs new file mode 100644 index 00000000..e69fdcc8 --- /dev/null +++ b/src/logic/item_symbol.rs @@ -0,0 +1,119 @@ +use pancurses; +use model; +use item_template; + +fn misc_object_symbol(subtype: item_template::MiscTemplate) -> pancurses::chtype { + match subtype { + item_template::MiscTemplate::RatSkeleton | + item_template::MiscTemplate::GiantCentipedeSkeleton => 's', + item_template::MiscTemplate::EmptyBottle => '!', + item_template::MiscTemplate::PotteryShard => '(', + item_template::MiscTemplate::HumanSkeleton | + item_template::MiscTemplate::DwarfSkeleton | + item_template::MiscTemplate::ElfSkeleton | + item_template::MiscTemplate::GnomeSkeleton => 's', + item_template::MiscTemplate::BrokenTeeth | + item_template::MiscTemplate::LargeBrokenBone | + item_template::MiscTemplate::BrokenStick => '~', + }.into() +} + +fn misc_symbol(subtype: item_template::MiscUsableTemplate) -> pancurses::chtype { + match subtype { + item_template::MiscUsableTemplate::FlaskOfOil => '!', + item_template::MiscUsableTemplate::IronSpike => '~', + item_template::MiscUsableTemplate::Statue => '~', + item_template::MiscUsableTemplate::Teeth => 's', + item_template::MiscUsableTemplate::SilverCross | + item_template::MiscUsableTemplate::GoldCross | + item_template::MiscUsableTemplate::MithrilCross | + item_template::MiscUsableTemplate::Cross => '~', + item_template::MiscUsableTemplate::CorkedBottle => '!' + }.into() +} + +pub fn generate(item: &model::Item, item_type: model::ItemType) -> pancurses::chtype { + match item_type { + model::ItemType::MiscObject(subtype) => misc_object_symbol(subtype), + model::ItemType::Chest(_) => 's'.into(), + model::ItemType::MiscUsable(subtype) => misc_symbol(subtype), + model::ItemType::Spike(_) => '~'.into(), + model::ItemType::FlaskOfOil(_) => '!'.into(), + model::ItemType::Jewelry(_) => '*'.into(), + model::ItemType::Bag(_) => '~'.into(), + model::ItemType::Gem(_) => '*'.into(), + model::ItemType::WearableGem(_) => '*'.into(), + model::ItemType::SlingAmmo(_) | + model::ItemType::Bolt(_) | + model::ItemType::Arrow(_) => '{'.into(), + model::ItemType::LightSource(_) => '~'.into(), + model::ItemType::Bow(_) | + model::ItemType::Crossbow(_) | + model::ItemType::Sling(_) => '}'.into(), + model::ItemType::Axe(_) => '\\'.into(), + model::ItemType::Polearm(_) => '/'.into(), + model::ItemType::Dagger(_) => '|'.into(), + model::ItemType::Sword(_) => '|'.into(), + model::ItemType::Pick(_) => '\\'.into(), + model::ItemType::Mace(_) => '\\'.into(), + model::ItemType::Boots(_) | + model::ItemType::Gloves(_) | + model::ItemType::Cloak(_) | + model::ItemType::Helm(_) => ']'.into(), + model::ItemType::Shield(_) => ')'.into(), + model::ItemType::HardArmor(_) => '['.into(), + model::ItemType::SoftArmor(_) => '('.into(), + model::ItemType::Bracers(_) | + model::ItemType::Belt(_) => ']'.into(), + model::ItemType::Amulet(_) => '"'.into(), + model::ItemType::Ring(_) => '='.into(), + model::ItemType::Staff(_) => '_'.into(), + model::ItemType::Wand(_) => '-'.into(), + model::ItemType::Scroll(_) => '?'.into(), + model::ItemType::Potion(_) => '!'.into(), + model::ItemType::Food(_) | + model::ItemType::JunkFood(_) => ','.into(), + model::ItemType::Chime(_) | + model::ItemType::Horn(_) => '%'.into(), + model::ItemType::MagicBook(_) | + model::ItemType::PrayerBook(_) => '?'.into(), + model::ItemType::Instrument(_) => '%'.into(), + model::ItemType::SongBook(_) => '?'.into(), + model::ItemType::LodgingAtInn(_) => '.'.into(), + model::ItemType::Money(_) => '$'.into(), + model::ItemType::UnseenTrap(_) => '.'.into(), + model::ItemType::SeenTrap(_) => '^'.into(), + model::ItemType::Rubble(_) => '+'.into(), + model::ItemType::OpenDoor(_) => '\''.into(), + model::ItemType::ClosedDoor(_) => '+'.into(), + model::ItemType::UpStaircase(_) => '<'.into(), + model::ItemType::DownStaircase(_) => '>'.into(), + model::ItemType::SecretDoor(_) => '#'.into(), + model::ItemType::EntranceToStore(_) => { + match item.subval { + 101 => 'G' as pancurses::chtype| pancurses::A_BOLD, // General store + 102 => 'R' as pancurses::chtype| pancurses::A_BOLD, // Armory + 103 => 'W' as pancurses::chtype| pancurses::A_BOLD, // Weapon smith + 104 => 'T' as pancurses::chtype| pancurses::A_BOLD, // Temple + 105 => 'A' as pancurses::chtype| pancurses::A_BOLD, // Alchemy Shop + 106 => 'M' as pancurses::chtype| pancurses::A_BOLD, // Magic shop + 107 => 'I' as pancurses::chtype| pancurses::A_BOLD, // Inn + 109 => 'L' as pancurses::chtype| pancurses::A_BOLD, // Library + 110 => 'U' as pancurses::chtype| pancurses::A_BOLD, // Music shop + 113 => 'J' as pancurses::chtype| pancurses::A_BOLD, // Gem store + 116 => 'D' as pancurses::chtype| pancurses::A_BOLD, // Deli + 118 => '+' as pancurses::chtype, // Black market + 108 => 'P' as pancurses::chtype| pancurses::A_BOLD, // Trading post + 111 => 'N' as pancurses::chtype| pancurses::A_BOLD, // Insurance shop + 112 => 'B' as pancurses::chtype| pancurses::A_BOLD, // Bank + 114 => 'X' as pancurses::chtype| pancurses::A_BOLD, // Money exchange + 115 => 'C' as pancurses::chtype| pancurses::A_BOLD, // Casino + 117 => 'Q' as pancurses::chtype| pancurses::A_BOLD, // Quest house + _ => '+' as pancurses::chtype, + } + }, + model::ItemType::UpSteepStaircase(_) => '<'.into(), + model::ItemType::DownSteepStaircase(_) => '>'.into(), + model::ItemType::Whirlpool(_) => '&'.into(), + } +} diff --git a/src/logic/mod.rs b/src/logic/mod.rs index cfd4c483..58234759 100644 --- a/src/logic/mod.rs +++ b/src/logic/mod.rs @@ -2,3 +2,5 @@ pub mod menu; pub mod use_item; pub mod generate_item; pub mod generate_item_interop; +pub mod item_name; +pub mod item_symbol; diff --git a/src/logic/use_item.rs b/src/logic/use_item.rs index 7973b6a2..eb61341c 100644 --- a/src/logic/use_item.rs +++ b/src/logic/use_item.rs @@ -18,27 +18,26 @@ pub fn class_can_use_item(class: &Class, item: &Item) -> bool { */ match item.item_type() { // Utility: - ItemType::LightSource => true, - ItemType::Staff => true, + ItemType::LightSource(_) => true, + ItemType::Staff(_) => true, // Weapons: - ItemType::RangedWeapon => item.subval == 20, // Sling - ItemType::PoleArm => item.subval == 8, - ItemType::Dagger => true, - ItemType::HaftedWeapon => false, - ItemType::Sword => false, // No scimitar - ItemType::Maul => item.subval == 6 || item.subval == 13, + ItemType::Sling(_) => true, // Sling + ItemType::Polearm(_) => item.subval == 8, + ItemType::Dagger(_) => true, + ItemType::Axe(_) => false, + ItemType::Sword(_) => false, // No scimitar + ItemType::Mace(_) => item.subval == 6 || item.subval == 13, // Armor - ItemType::GemHelm => false, // Only metal atm - ItemType::Boots => true, - ItemType::Gloves => item.subval != 2, - ItemType::Cloak => true, - ItemType::Helm => item.subval == 1, - ItemType::Shield => item.subval <= 3, - ItemType::SoftArmor => item.subval <= 6, - ItemType::Bracers => item.subval <= 3, - ItemType::Belt => true, + ItemType::Boots(_) => true, + ItemType::Gloves(_) => item.subval != 2, + ItemType::Cloak(_) => true, + ItemType::Helm(_) => item.subval == 1, + ItemType::Shield(_) => item.subval <= 3, + ItemType::SoftArmor(_) => item.subval <= 6, + ItemType::Bracers(_) => item.subval <= 3, + ItemType::Belt(_) => true, _ => false, } }, @@ -49,30 +48,31 @@ pub fn class_can_use_item(class: &Class, item: &Item) -> bool { */ match item.item_type() { // Utility: - ItemType::LightSource => true, - ItemType::Staff => true, - ItemType::Pick => true, - ItemType::Ring => true, - ItemType::Amulet => true, + ItemType::LightSource(_) => true, + ItemType::Staff(_) => true, + ItemType::Pick(_) => true, + ItemType::Ring(_) => true, + ItemType::Amulet(_) => true, // Weapons: - ItemType::RangedWeapon => true, - ItemType::PoleArm => true, - ItemType::Dagger => true, - ItemType::HaftedWeapon => true, - ItemType::Sword => true, - ItemType::Maul => true, + ItemType::Bow(_) => true, + ItemType::Crossbow(_) => true, + ItemType::Sling(_) => true, + ItemType::Polearm(_) => true, + ItemType::Dagger(_) => true, + ItemType::Axe(_) => true, + ItemType::Sword(_) => true, + ItemType::Mace(_) => true, // Armor - ItemType::GemHelm => true, - ItemType::Boots => true, - ItemType::Gloves => true, - ItemType::Cloak => true, - ItemType::Helm => true, - ItemType::Shield => true, - ItemType::SoftArmor => true, - ItemType::Bracers => true, - ItemType::Belt => true, + ItemType::Boots(_) => true, + ItemType::Gloves(_) => true, + ItemType::Cloak(_) => true, + ItemType::Helm(_) => true, + ItemType::Shield(_) => true, + ItemType::SoftArmor(_) => true, + ItemType::Bracers(_) => true, + ItemType::Belt(_) => true, _ => false, } } diff --git a/src/menu/create_character.rs b/src/menu/create_character.rs index 35839025..cfdd4bfe 100644 --- a/src/menu/create_character.rs +++ b/src/menu/create_character.rs @@ -1045,7 +1045,7 @@ fn add_equipment() { general_starting_items.push(torch); let light_cloak = generate_item::create_item(Box::new(item_template::CloakTemplate::LightCloak), 0); general_starting_items.push(light_cloak); - let soft_leather_armor = generate_item::create_item(Box::new(item_template::ArmorTemplate::SoftLeatherArmor), 0); + let soft_leather_armor = generate_item::create_item(Box::new(item_template::SoftArmorTemplate::SoftLeatherArmor), 0); general_starting_items.push(soft_leather_armor); for item in general_starting_items { diff --git a/src/misc.c b/src/misc.c index 1e93f917..7f55f30c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -24,70 +24,18 @@ void C_print_new_spell_line(uint8_t i, long slot, long failchance); static long tcptr; /* { Cur treasure heap ptr} */ static long mfptr; /* { Cur free monster ptr } */ -static treasure_type up_stair = {"an up staircase", - up_staircase, - 0x00000000, - 0x00000000, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - "1d1", - 0, - 0}; -static treasure_type down_stair = {"a down staircase", - down_staircase, - 0x00000000, - 0x00000000, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - "1d1", - 0, - 0}; -static treasure_type up_steep = {"a steep staircase", - up_steep_staircase, - 0x00000000, - 0x00000000, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - "1d1", - 0, - 0}; -static treasure_type down_steep = {"a steep staircase", - down_steep_staircase, - 0x00000000, - 0x00000000, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - "1d1", - 0, - 0}; +static treasure_type up_stair = {up_staircase, + 0x00000000, 0x00000000, 0, 0, 1, 0, 0, + 0, 0, 0, 0, "1d1", 0, 0}; +static treasure_type down_stair = {down_staircase, + 0x00000000, 0x00000000, 0, 0, 1, 0, 0, + 0, 0, 0, 0, "1d1", 0, 0}; +static treasure_type up_steep = {up_steep_staircase, + 0x00000000, 0x00000000, 0, 0, 1, 0, 0, + 0, 0, 0, 0, "1d1", 0, 0}; +static treasure_type down_steep = {down_steep_staircase, + 0x00000000, 0x00000000, 0, 0, 1, 0, 0, + 0, 0, 0, 0, "1d1", 0, 0}; static monster_type blank_monster = /* { Blank monster values } */ {0, 0, 0, 0, 0, 0, 0, 0, 0, false, false, false}; @@ -2618,7 +2566,7 @@ void place_open_door(long y, long x) { popt(&cur_pos); cave[y][x].tptr = cur_pos; - t_list[cur_pos] = door_list[0]; + t_list[cur_pos] = door_open; cave[y][x].fval = corr_floor3.ftval; cave[y][x].fopen = true; } @@ -2631,7 +2579,7 @@ void place_broken_door(long y, long x) { popt(&cur_pos); cave[y][x].tptr = cur_pos; - t_list[cur_pos] = door_list[0]; + t_list[cur_pos] = door_open; cave[y][x].fval = corr_floor3.ftval; cave[y][x].fopen = true; t_list[cur_pos].p1 = 1; @@ -2645,7 +2593,7 @@ void place_closed_door(long y, long x) { popt(&cur_pos); cave[y][x].tptr = cur_pos; - t_list[cur_pos] = door_list[1]; + t_list[cur_pos] = door_closed; cave[y][x].fval = corr_floor3.ftval; cave[y][x].fopen = false; } @@ -2658,7 +2606,7 @@ void place_locked_door(long y, long x) { popt(&cur_pos); cave[y][x].tptr = cur_pos; - t_list[cur_pos] = door_list[1]; + t_list[cur_pos] = door_closed; cave[y][x].fval = corr_floor3.ftval; cave[y][x].fopen = false; t_list[cur_pos].p1 = randint(10) + 10; @@ -2672,7 +2620,7 @@ void place_stuck_door(long y, long x) { popt(&cur_pos); cave[y][x].tptr = cur_pos; - t_list[cur_pos] = door_list[1]; + t_list[cur_pos] = door_closed; cave[y][x].fval = corr_floor3.ftval; cave[y][x].fopen = false; t_list[cur_pos].p1 = -randint(10) - 10; @@ -2686,7 +2634,7 @@ void place_secret_door(long y, long x) { popt(&cur_pos); cave[y][x].tptr = cur_pos; - t_list[cur_pos] = door_list[2]; + t_list[cur_pos] = door_secret; cave[y][x].fval = corr_floor4.ftval; cave[y][x].fopen = false; } diff --git a/src/model/identified_record.rs b/src/model/identified_record.rs deleted file mode 100644 index da8beedd..00000000 --- a/src/model/identified_record.rs +++ /dev/null @@ -1,12 +0,0 @@ -use libc; - -use thirdparty::serde::BigArray; - -use constants; - -#[repr(C)] -#[derive(Serialize, Deserialize)] -pub struct IdentifiedRecord { - #[serde(with = "BigArray")] - pub list: [libc::uint8_t; constants::MAX_OBJECTS + 1], -} diff --git a/src/model/item.rs b/src/model/item.rs index 537a818c..82a7a786 100644 --- a/src/model/item.rs +++ b/src/model/item.rs @@ -1,20 +1,10 @@ -use std::borrow::Cow; -use model::ItemType; -use misc; use libc; -use model::{ Damage, Name }; - -use thirdparty::serde::BigArray; +use model; +use identification; #[repr(C)] #[derive(Copy, Clone, Serialize, Deserialize)] -// For more info. Se item_guide.txt -// TODO: tval + subval needs bit for is_identified pub struct Item { // treasure_type - // Object name. See below for rules on names. - #[serde(with = "BigArray")] - pub name: Name, - // Object type. Literally, is what kind of object it is. pub tval: libc::uint8_t, @@ -56,7 +46,7 @@ pub struct Item { // treasure_type // the amount of damage an item does to monster. everything // should have a damage value, even if it's just "0d0". - pub damage: Damage, + pub damage: model::Damage, // a vague measurement of how strong an item's magic is. pub level: libc::int8_t, @@ -66,771 +56,19 @@ pub struct Item { // treasure_type } impl Item { - fn number_of_string<'a>(&self) -> Cow<'a, str> { - match self.number { - 0 => Cow::from("no more "), - 1 => Cow::from(""), - _ => Cow::from(self.number.to_string() + " "), - } - } - - fn subtype_name<'a>(&self) -> Cow<'a, str> { - let plural_s = || if self.number == 1 { "s" } else { "" }; - match self.item_type() { - ItemType::Food => - if 255 < self.subval && self.subval < 300 { - // Mushrooms - let attribute = match self.subval { - 256 => "", - 257 => " of poison", - 258 => " of blindness", - 259 => " of paranoia", - 260 => " of confusion", - 261 => " of hallucination", - 262 => " of cure poison", - 263 => " of cure blindness", - 264 => " of cure paranoia", - 265 => " of cure confusion", - 266 => " of weakness", - 267 => " of unhealth", - 268 => " of restore constitution", - 269 => " of first aid", - 270 => " of minor cures", - 271 => " of light cures", - 272 => " of restoring", - 273 => " of poison", - 274 => " of hallucination", - 275 => " of cure poison", - 276 => " of unhealth", - 277 => " of cure serious wounds", - _ => "of ???", - }; - Cow::from( - format!("%M mushroom{}{}", plural_s(), if self.is_identified() { - attribute } else {""} )) - } else { - Cow::from(match self.subval { - 307 => format!("Ration{} of food", plural_s()), - 309 => format!("Hard biscuit{}", plural_s()), - 310 => format!("Strip{} of beef jerky", plural_s()), - 311 => format!("Pint{} of fine ale", plural_s()), - 312 => format!("Pint{} of fine wine", plural_s()), - 313 => format!("Piece{} of elvish waybread", plural_s()), - 314 => format!("Stew{}", plural_s()), - 315 => format!("Green jelly{}", plural_s()), - 316 => format!("Handful{} of berries (poisonous)", plural_s()), - 317 => format!("Handful{} of berries (smurfberries)", plural_s()), - 319 => format!("Eyeball{} of Ned", plural_s()), - 252 => format!("Pint{} of fine grade mush", plural_s()), - _ => "Alien food".to_string(), - }) - }, - ItemType::Dagger => - Cow::from(match self.subval { - 1 => "Main gauche", - 2 => "Misercorde", - 3 => "Stiletto", - 4 => "Bodkin", - 5 => "Broken dagger", - 8 => "Bilbo", - 9 => "Baselard", - 16 => "Foil", - 20 => "Rapier", - 22 => "Small sword", - //5 => "Cat-O-Nine Tails", - _ => "Alien dagger", - }), - ItemType::Sword => - Cow::from(match self.subval { - 6 => "Backsword", - 7 => "Bastard sword", - 10 => "Broadsword", - 11 => "Claymore", - 12 => "Cutlass", - 13 => "Espadon", - 14 => "Executioner's sword", - 15 => "Flamberge", - 17 => "Katana", - 18 => "Longsword", - 19 => "No-dachi", - 21 => "Sabre", - 23 => "Zweihander", - 24 => "Broken sword", - _ => "Alien sword", - }), - ItemType::HaftedWeapon => - Cow::from(match self.subval { - 1 => "Balestarius", - 3 => "Battle axe", - 4 => "Broad axe", - _ => "Alien hafted weapon", - }), - ItemType::Maul => - Cow::from(match self.subval { - 2 => "Ball and chain", - 6 => "Wooden club", - 7 => "Flail", - 8 => "Two handed great flail", - 9 => "Morningstar", - 10 => "Mace", - 11 => "War hammer", - 12 => "Lead filled mace", - 13 => "Iron-shod quarterstaff", - _ => "Alien maul", - }), - ItemType::PoleArm => - Cow::from(match self.subval { - 1 => "Awl-pike", - 2 => "Beaked axe", - 3 => "Fauchard", - 4 => "Glaive", - 5 => "Halberd", - 6 => "Lucerne hammer", - 7 => "Pike", - 8 => "Spear", - 9 => "Lance", - 10 => "Javelin", - _ => "Alien polearm", - }), - ItemType::RangedWeapon => - Cow::from(match self.subval { - 1 => "Short bow", - 2 => "Long bow", - 3 => "Composite bow", - 10 => "Light crossbow", - 11 => "Heavy crossbow", - 20 => "Sling", - _ => "Alien ranged weapon", - }), - ItemType::Arrow => Cow::from(format!("Arrow{}", plural_s())), - ItemType::Bolt => Cow::from(format!("Bolt{}", plural_s())), - ItemType::SlingAmmo => Cow::from(format!("Rounded pebble{}", plural_s())), - ItemType::Spike => Cow::from(format!("Iron spike{}", plural_s())), - ItemType::LightSource => - match self.subval { - 1 => Cow::from("Brass lantern"), - 2 => Cow::from("Brass lantern"), - 13 => Cow::from("Wooden lantern"), - 14 => Cow::from("Wooden torch"), - 15 => Cow::from("Magic torch"), - 17 => Cow::from("Magic lantern"), - _ => Cow::from("Alien lightsource"), - }, - ItemType::Pick => - Cow::from(match self.subval { - 1 => "Pick", - 2 => "Shovel", - //2 => "Orcish Pick", - 3 => "Dwarven pick", - 5 => "Gnomish shovel", - 6 => "Dwarven shovel", - 7 => "Orcish pick", - _ => "Alien pick", - }), - ItemType::Boots => - Cow::from(match self.subval { - 1 => "Pair of soft leather shoes", - 2 => "Pair of soft leather boots", - 3 => "Pair of hard leather boots", - 4 => "Pair of sandals", - _ => "Alien boots", - }), - ItemType::Helm => - Cow::from(match self.subval { - 1 => "Soft leather cap", - 2 => "Hard leather cap", - 3 => "Metal cap", - 4 => "Iron helm", - 5 => "Steel helm", - 6 => "Silver crown", - 7 => "Golden crown", - 8 => "Jewel encrusted crown", - 11 => "Cloth hat", - _ => "Alien helm", - }), - ItemType::GemHelm => { - let material = match self.subval { - 9 => "Iron helm", - 10 => "Steel helm", - _ => "Alien helm", - }; - Cow::from(format!("{}{}", material, - if self.is_identified() { - "of gems" } else { "" })) - }, - ItemType::WearableGem => { - let attribute = match self.subval { - 1 => "of teleportation", - 2 => "of resist cold", - 3 => "of resist acid", - 4 => "of see invisible", - 5 => "of stealth", - 6 => "of slow digestation", - 7 => "of lordly protection (FIRE)", - _ => "of ???", - }; - Cow::from(format!("Finely cut %R{}", if self.is_identified() { - attribute} else {""})) - }, - ItemType::SoftArmor => - Cow::from(match self.subval { - 1 => "Robe", - 2 => "Soft leather armor", - 3 => "Soft studded leather", - 4 => "Hard leather armor", - 5 => "Hard studded leather", - 6 => "Woven cord armor", - 7 => "Soft leather ring mail", - 8 => "Hard leather ring mail", - 9 => "Leather scale mail", - 10 => "Leather bridantine armor", - 11 => "Cool set of threads", - 12 => "Filthy naga hide armor", - 13 => "Elven chain mail", - 99 => "Some filthy rags", - _ => "Alien soft armor", - }), - ItemType::HardArmor => - Cow::from(match self.subval { - 1 => "Metal scale mail", - 2 => "Chain mail", - 3 => "Rusty chain mail", - 4 => "Double chain mail", - 5 => "Augmented chain mail", - 6 => "Bar chain mail", - 7 => "Metal brindandine armor", - 8 => "Laminated armor", - 9 => "Partial plate armor", - 10 => "Metal lamellar armor", - 11 => "Full plate armor", - 12 => "Ribbed plate armor", - 13 => "Bronze plate mail", - 14 => "Stone plate armor", - 15 => "Mithril chain mail", - 16 => "Mithril plate armor", - _ => "Alien hard armor", - }), - ItemType::Cloak => Cow::from("Cloak"), - ItemType::Gloves => - Cow::from(match self.subval { - 1 => "Set of leather gloves", - 2 => "Set of gauntlets", - 5 => "Set of cloth gloves", - _ => "Alien gloves", - }), - ItemType::Bracers => - match self.subval { - 1 => Cow::from( - format!("Set of bracers{}", if self.is_identified() { - " of protection" } else { "" })), - 2 => Cow::from( - format!("Set of bracers{}", if self.is_identified() { - " of defence" } else { "" })), - 3 => Cow::from( - format!("Set of bracers{}", if self.is_identified() { - " of shielding" } else { "" })), - 4 => Cow::from("Set of mithril bracers"), - 5 => Cow::from("Set of adamantite bracers"), - 6 => Cow::from( - format!("Set of bracers{}", if self.is_identified() { - " of weapon attraction" } else { "" })), - 30 => Cow::from("Small silver bracelet"), - 31 => Cow::from( - format!("Small silver bracelet{}", if self.is_identified() { - " of warding" } else { "" })), - 40 => Cow::from("Small gold bracelet"), - 50 => Cow::from("Small platinum bracelet"), - _ => Cow::from("Alien bracers"), - }, - ItemType::Belt => - Cow::from(match self.subval { - 1 => "Girdle", - 10 => "Silver belt buckle", - 11 => "Gold belt buckle", - 13 => "Leather belt", - _ => "Alien belt", - }), - ItemType::Shield => - Cow::from(match self.subval { - 1 => "Small leather shield", - 2 => "Medium leather shield", - 3 => "Large leather shield", - 4 => "Small metal shield", - 5 => "Medium metal shield", - 6 => "Large metal shield", - _ => "Alien shield", - }), - ItemType::Ring => { - let attribute = if self.is_identified() { - match self.subval { - 1 => " of gain strength", - 2 => " of gain dexterity", - 3 => " of gain constitution", - 4 => " of gain intelligence", - 7 => " of speed", - 8 => " of searching", - 9 => " of teleportation", - 10 => " of slow digestion", - 11 => " of resist fire", - 12 => " of resist cold", - 13 => " of feather falling", - 14 => " of adornment", - 15 => " of adornment", - 16 => " of weakness", - 17 => " of lordly protection (FIRE)", - 18 => " of lordly protection (ACID)", - 19 => " of lordly protection (COLD)", - 20 => " of WOE", - 21 => " of stupidity", - 22 => " of increase damage", - 23 => " of increase to-hit", - 24 => " of protection", - 25 => " of aggravate monster", - 26 => " of see invisible", - 27 => " of sustain strength", - 28 => " of sustain intelligence", - 29 => " of sustain wisdom", - 30 => " of sustain constitution", - 31 => " of sustain dexterity", - 32 => " of sustain charisma", - 33 => " of slaying", - 34 => " of gnomekind", - 35 => " of speed", - _ => " of ???", - } - } else { - "" - }; - Cow::from(format!("%R Ring{}", attribute)) - }, - ItemType::Amulet => - match self.subval { - 5 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of wisdom"} else {""})), - 6 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of charisma"} else {""})), - 7 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of searching"} else {""})), - 8 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of teleportation"} else {""})), - 9 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of slow digestation"} else {""})), - 10 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of resist acid"} else {""})), - 11 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of adornment"} else {""})), - 12 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of adornment"} else {""})), - 13 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of the magi"} else {""})), - 14 => Cow::from( - format!("%A amulet{}", if self.is_identified() { - "of DOOM"} else {""})), - 30 => Cow::from("Finely wrought silver necklace"), - 40 => Cow::from("Finely wrought gold necklace"), - 60 => Cow::from("Finely wrought mithril necklace"), - _ => Cow::from("%A Alien amulet"), - }, - ItemType::MiscUsable => - Cow::from(match self.subval { - 14 => "%A Statue", - 15 => "Broken set of teeth", - 16 => "Silver cross", - 17 => "Gold cross", - 18 => "Mithril cross", - 19 => "%M cross", - 20 => "%M cross", - 21 => "Corked bottle", - 22 => "Holy hand grenade of Antioch", - _ => "Alien thing", - }), - ItemType::Chime => { - let attribute = if self.is_identified() { - match self.subval { - 1 => " of light", - 2 => " of detect doors/stairs", - 3 => " of detect traps", - 4 => " of teleportation", - 5 => " of thunderblasts", - 6 => " of summon monster", - 7 => " of disarming", - 8 => " of aggravation", - 9 => " of slow monster", - 10 => " of soothe monster", - 11 => " of cure light wound", - 12 => " of changing", - 13 => " of remove curse", - 14 => " of curing", - 15 => " of dispel evil", - 16 => " of darkness", - _ => " of ???", - } - } else { - "" - }; - Cow::from(format!("%M chime{}", attribute)) - }, - ItemType::Horn => { - let attribute = if self.is_identified() { - match self.subval { - 1 => " of bubbles", - 2 => " of calling", - 3 => " of soft sounds", - 4 => " of *Blasting*", - 5 => " of cold", - 6 => " of heat", - 7 => " of gas", - 8 => " of recall", - 9 => " of *Chaos*", - 10 => " of glue", - 11 => " of valhalla", - 12 => " of tritons", - 13 => " of fog", - _ => " of ???H", - } - } else { - "" - }; - Cow::from(format!("%H{}", attribute)) - }, - ItemType::Instrument => - Cow::from(match self.subval { - 258 => "Pipes of Peace", - 259 => "Lyre of Nature", - 260 => "Lute of the Woods", - 261 => "Harp of the Druids", - _ => "Alien instrument", - }), - ItemType::SongBook => - Cow::from(match self.subval { - 262 => "Book of Bard Lyrics [Beginners Handbook]", - 263 => "Songs of Charming [Song Book I]", - 264 => "Ballads of Knowledge [Song Book II]", - 265 => "Epics of the Bards [Greater Song Book]", - _ => "Alien book", - }), - ItemType::Scroll1 => { - let attribute = if self.is_identified() { - match self.subval { - 257 => " of Enchant Weapon To-Hit", - 258 => " of Enchant Weapon To-Dam", - 259 => " of Enchant Armor", - 260 => " of Identify", - 261 => " of Remove Curse", - 262 => " of Light", - 263 => " of Summon Monster", - 264 => " of Phase Door", - 265 => " of Teleport", - 266 => " of Teleport Level", - 267 => " of Monster Confusion", - 268 => " of Magic Mapping", - 269 => " of Sleep Monster", - 270 => " of Rune of Protection", - 271 => " of Treasure Detection", - 272 => " of Object Detection", - 273 => " of Trap Detection", - 274 => " of Door/Stair Location", - 275 => " of Mass Genocide", - 276 => " of Detect Invisible", - 277 => " of Aggravate Monster", - 278 => " of Trap Creation", - 279 => " of Trap/Door Destruction", - 280 => " of Door Creation", - 281 => " of Recharging", - 282 => " of Genocide", - 283 => " of Darkness", - 284 => " of Protection from Evil", - 285 => " of Create Food", - 286 => " of Dispel Undead", - /* 257 => " of *Enchant Weapon*", - 258 => " of Curse Weapon", - 259 => " of *Enchant Armor*", - 260 => " of Curse Armor", - 261 => " of Summon Undead", - 262 => " of Blessing", - 263 => " of Holy Chant", - 264 => " of Holy Prayer", - 265 => " of Word-of-Recall", - 266 => " of *Destruction*", - 267 => " of Wishing", - 268 => " of Feign Death", - 269 => " of Make Munchies", */ - _ => "of ??", - } - } else { - "" - }; - Cow::from(format!("Scroll{}{}", plural_s(), attribute)) - }, - ItemType::Potion1 => { - let material = match self.subval { - 281 => "Icky green", - 282 => "Light brown", - 283 => "Clear", - _ => "%C", - }; - let attribute = if self.is_identified() { - match self.subval { - 257 => " of Gain Strength", - 258 => " of Poison", - 259 => " of Restore Strength", - 260 => " of Gain Intelligence", - 261 => " of Lose Intelligence", - 262 => " of Restore Intelligence", - 263 => " of Gain Wisdom", - 264 => " of Lose Wisdom", - 265 => " of Restore Wisdom", - 266 => " of Charisma", - 267 => " of Ugliness", - 268 => " of Restore Charisma", - 269 => " of Cure Light Wounds", - 270 => " of Cure Serious Wounds", - 271 => " of Cure Critical Wounds", - 272 => " of Healing", - 273 => " of Gain Constitution", - 274 => " of Gain Experience", - 275 => " of Sleep", - 276 => " of Blindness", - 277 => " of Confusion", - 278 => " of Poison", - 279 => " of Haste Self", - 280 => " of Slowness", - 281 => " of Slime Mold Juice", - 282 => " of Apple Juice", - 283 => " of Water", - 284 => " of Gain Dexterity", - 285 => " of Restore Dexterity", - 286 => " of Restore Constitution", - 287 => " of Learning", - 288 => " of Lose Memories", - 289 => " of Salt Water", - 290 => " of Invulnerability", - 291 => " of Heroism", - 292 => " of Super Heroism", - 293 => " of Boldliness", - 294 => " of Restore Life Levels", - 295 => " of Resist Heat", - 296 => " of Resist Cold", - 297 => " of Detect Invisible", - 298 => " of Slow Poison", - 299 => " of Neutralize Poison", - 300 => " of Restore Mana", - 301 => " of Infra-Vision", - 302 => " of Flea Bile", - _ => " of ???", - } - } else { - "" - }; - Cow::from(format!("{} potion{}{}", material, plural_s(), attribute)) - }, - ItemType::FlaskOfOil => Cow::from(format!("Flask{} of Oil", plural_s())), - ItemType::Wand => { - let attribute = if self.is_identified() { - match self.subval { - 1 => " of Light", - 2 => " of Lightning Bolts", - 3 => " of Frost Bolts", - 4 => " of Fire Bolts", - 5 => " of Stone-to-Mud", - 6 => " of Polymorph", - 7 => " of Heal Monster", - 8 => " of Haste Monster", - 9 => " of Slow Monster", - 10 => " of Confuse Monster", - 11 => " of Sleep Monster", - 12 => " of Drain Life", - 13 => " of Trap/Door destruction", - 14 => " of Magic Missile", - 15 => " of Wall Building", - 16 => " of Clone Monster", - 17 => " of Teleport Away", - 18 => " of Disarming", - 19 => " of Lightning Balls", - 20 => " of Cold Balls", - 21 => " of Fire Balls", - 22 => " of Stinking Cloud", - 23 => " of Acid Balls", - 24 => " of Wonder", - 25 => " of Probing", - _ => "of ???", - } - } else { - "" - }; - let charges = if self.is_identified() { - " (%P1 charges)" - } else { "" }; - Cow::from(format!("%M wand{}{}", attribute, charges)) - }, - ItemType::Staff => { - let attribute = if self.is_identified() { - match self.subval { - 1 => " of Light", - 2 => " of Door/Stair Location", - 3 => " of Trap Location", - 4 => " of Treasure Location", - 5 => " of Object Location", - 6 => " of Teleportation", - 7 => " of Earthquakes", - 8 => " of Summoning", - 10 => " of *Destruction*", - 11 => " of Starlite", - 12 => " of Haste Monsters", - 13 => " of Slow Monsters", - 14 => " of Sleep Monsters", - 15 => " of Cure Light Wounds", - 16 => " of Detect Invisible", - 17 => " of Speed", - 18 => " of Slowness", - 19 => " of Mass Polymorph", - 20 => " of Remove Curse", - 21 => " of Detect Evil", - 22 => " of Curing", - 23 => " of Dispel Evil", - 25 => " of Darkness", - 26 => " of Identify", - _ => "of ???", - } - } else { - "" - }; - let charges = if self.is_identified() { - " (%P1 charges)" - } else { "" }; - Cow::from(format!("%W wand{}{}", attribute, charges)) - }, - ItemType::MagicBook => { - let name = if self.is_identified() { - match self.subval { - 257 => " of Magic Spells [Beginners-Magik]", - 258 => " of Magic Spells [Magik I]", - 259 => " of Magic Spells [Magik II]", - 261 => " of Magic Spells [The Mages Guide to Power]", - _ => " of ???", - } - } else { - "" - }; - Cow::from(format!("Book{}{}", plural_s(), name)) - }, - ItemType::PrayerBook => { - let name = if self.is_identified() { - match self.subval { - 258 => " of Prayers [Beginners Handbook]", - 259 => " of Prayers [Words of Wisdom]", - 260 => " of Prayers [Chants and Blessings]", - 261 => " of Prayers [Exorcism and Dispelling]", - _ => " of ???", - } - } else { - "" - }; - Cow::from(format!("Holy Book{}{}", plural_s(), name)) - }, - ItemType::Chest => - Cow::from(match self.subval { - 1 => "Small wooden chest", - 4 => "Large wooden chest", - 5 => "Dead human body", - 7 => "Small iron chest", - 10 => "Large iron chest", - 13 => "Small steel chest", - 16 => "Large steel chest", - _ => "Alien chest", - }), - ItemType::Bag => { - let attribute = if self.is_identified() { - match self.subval { - 1 => " of Holding (250)", - 2 => " of Holding (500)", - 3 => " of Holding (1000)", - //3 => "%N Bag of Holding (1500)", - 4 => " of Devouring", - _ => " of ???", - } - } else { "" }; - Cow::from(format!("%N Bag{}", attribute)) - }, - ItemType::MiscObject => - Cow::from(match self.subval { - 1 => "Rat skeleton", - 2 => "Giant centipede skeleton", - 4 => "Empty bottle", - 5 => "Broken set of pottery", - 7 => "Human skeleton", - 8 => "Dwarf skeleton", - 9 => "Elf skeleton", - 10 => "Gnome skeleton", - 11 => "Broken set of teeth", - 12 => "Large broken bone", - 13 => "Broken stick", - _ => "Alien thing", - }), - _ => Cow::from("Something alien"), - } + pub fn item_type(&self) -> model::ItemType { + model::ItemType::from(self.tval) } - fn damage_string<'a>(&self) -> Cow<'a, str> { - let raw_string = self.damage.iter().map(|&i| i as u8).collect::>(); - let damage_string = misc::c_array_to_rust_string(raw_string); - Cow::from(format!(" ({})", damage_string)) - } - - fn attack_enchantment_string<'a>(&self) -> Cow<'a, str> { - let tohit_sign = if self.tohit > 0 { "+" } else {""}; - let todam_sign = if self.todam > 0 { "+" } else {""}; - Cow::from(format!(" ({}{},{}{})", tohit_sign, self.tohit, todam_sign, self.todam)) - } - - fn armor_string<'a>(&self) -> Cow<'a, str> { - if self.ac == 0 && (!self.is_identified() || self.toac == 0) { - return Cow::from(""); + pub fn set_identified(&self, yn: bool) { + self.identified = if yn { 255 } else { 0 }; + if yn { + identification::set_item_type_identified(self.item_type(), self.subval, yn); } - - if !self.is_identified() { - return Cow::from(format!(" [{}]", self.ac)); - } - - let toac_sign = if self.toac > 0 { "+" } else {""}; - return Cow::from(format!(" [{},{}{}]", self.ac, toac_sign, self.toac)) - } - - pub fn item_type(&self) -> ItemType { - ItemType::from(self.tval) } pub fn is_identified(&self) -> bool { self.identified != 0 } - - // In progress.. - pub fn equipment_name(&self) -> String { - let mut parts = Vec::new(); - parts.push(self.number_of_string()); - parts.push(self.subtype_name()); - if self.item_type() == ItemType::LightSource { - let plural_s = if self.p1 == 0 { "" } else { "s" }; - parts.push(Cow::from(format!(" with {} turn{} of light", self.p1, plural_s))); - } - - if self.item_type().has_damage() { - parts.push(self.damage_string()); - } - if self.item_type().has_attack_enhancement() && self.is_identified() { - parts.push(self.attack_enchantment_string()); - } - parts.push(self.armor_string()); - parts.join("") - } } diff --git a/src/model/item_interop.rs b/src/model/item_interop.rs index bf05f749..3cf6aa05 100644 --- a/src/model/item_interop.rs +++ b/src/model/item_interop.rs @@ -1,15 +1,16 @@ -use model::{ Item, ItemType }; +use model; +use logic::item_symbol; use debug; use pancurses; #[no_mangle] -pub extern fn C_item_get_tchar(item_ptr: *const Item) -> pancurses::chtype { +pub extern fn C_item_get_tchar(item_ptr: *const model::Item) -> pancurses::chtype { debug::enter(&format!("C_item_get_tchar")); let item = unsafe { *item_ptr }; debug::info(&format!("(enter) symbol: {}, {}", item.tval, item.subval)); - let res = ItemType::from(item.tval).symbol(item.subval); + let res = item_symbol::generate(&item, item.item_type()); debug::leave("C_item_get_tchar"); res diff --git a/src/model/item_type.rs b/src/model/item_type.rs index f742dd60..3b035011 100644 --- a/src/model/item_type.rs +++ b/src/model/item_type.rs @@ -1,268 +1,81 @@ -use pancurses::{chtype, A_BOLD}; +use item_template; -#[derive(Debug, PartialEq)] +#[derive(Eq, PartialEq, Hash, Debug)] pub enum ItemType { - MiscObject = 1, - Chest = 2, - MiscUsable = 3, - Jewelry = 4, - Gem = 5, - Bag = 6, - WearableGem = 7, + MiscObject(item_template::MiscTemplate), + Chest(item_template::ChestTemplate), + MiscUsable(item_template::MiscUsableTemplate), + Jewelry(item_template::JewelryTemplate), + Gem(item_template::GemTemplate), + Bag(item_template::BagTemplate), + WearableGem(item_template::WearableGemTemplate), - SlingAmmo = 10, - Bolt = 11, - Arrow = 12, - Spike = 13, + SlingAmmo(item_template::AmmunitionTemplate), + Bolt(item_template::AmmunitionTemplate), + Arrow(item_template::AmmunitionTemplate), + Spike(item_template::MiscUsableTemplate), - LightSource = 15, + LightSource(item_template::LightSourceTemplate), - RangedWeapon = 20, - HaftedWeapon = 21, - PoleArm = 22, - Dagger = 23, - Sword = 24, - Pick = 25, - Maul = 26, + Bow(item_template::BowTemplate), + Crossbow(item_template::CrossbowTemplate), + Sling(item_template::SlingTemplate), - GemHelm = 29, - Boots = 30, - Gloves = 31, - Cloak = 32, - Helm = 33, - Shield = 34, - HardArmor = 35, - SoftArmor = 36, - Bracers = 37, - Belt = 38, + Axe(item_template::AxeTemplate), + Polearm(item_template::PolearmTemplate), + Dagger(item_template::DaggerTemplate), + Sword(item_template::SwordTemplate), + Pick(item_template::PickTemplate), + Mace(item_template::MaceTemplate), - Amulet = 40, + Boots(item_template::BootsTemplate), + Gloves(item_template::GlovesTemplate), + Cloak(item_template::CloakTemplate), + Helm(item_template::HelmTemplate), + Shield(item_template::ShieldTemplate), + HardArmor(item_template::HardArmorTemplate), + SoftArmor(item_template::SoftArmorTemplate), + Bracers(item_template::BracersTemplate), + Belt(item_template::BeltTemplate), - Ring = 45, + Amulet(item_template::AmuletTemplate), - Staff = 55, + Ring(item_template::RingTemplate), - Rod = 60, + Staff(item_template::StaffTemplate), - Wand = 65, - Scroll1 = 70, - Scroll2 = 71, + Wand(item_template::WandTemplate), + Scroll(item_template::ScrollTemplate), - Potion1 = 75, - Potion2 = 76, - FlaskOfOil = 77, + Potion(item_template::PotionTemplate), + FlaskOfOil(item_template::MiscUsableTemplate), - Food = 80, - JunkFood = 81, + Food(item_template::FoodTemplate), + JunkFood(item_template::JunkFoodTemplate), - Chime = 85, - Horn = 86, + Chime(item_template::ChimeTemplate), + Horn(item_template::HornTemplate), - MagicBook = 90, - PrayerBook = 91, - Instrument = 92, - SongBook = 93, + MagicBook(item_template::MagicBookTemplate), + PrayerBook(item_template::PrayerBookTemplate), + Instrument(item_template::InstrumentTemplate), + SongBook(item_template::SongBookTemplate), // Not Items, but yeah - LodgingAtInn = 95, - Money = 100, /* look in detect_item for limit */ - UnseenTrap = 101, - SeenTrap = 102, - Rubble = 103, - OpenDoor = 104, - ClosedDoor = 105, - UpStaircase = 107, - DownStaircase = 108, - SecretDoor = 109, - EntranceToStore = 110, - UpSteepStaircase = 111, - DownSteepStaircase = 112, - Whirlpool = 113, -} - -impl ItemType { - pub fn has_damage(&self) -> bool { - match self { - ItemType::SlingAmmo | ItemType::Bolt | ItemType::Arrow | ItemType::Spike - | ItemType::HaftedWeapon | ItemType::PoleArm - | ItemType::Dagger | ItemType::Sword | ItemType::Pick | ItemType::Maul - => true, - _ => false, - } - } - - pub fn has_attack_enhancement(&self) -> bool { - match self { - ItemType::SlingAmmo | ItemType::Bolt | ItemType::Arrow | ItemType::Spike - | ItemType::RangedWeapon | ItemType::HaftedWeapon | ItemType::PoleArm - | ItemType::Dagger | ItemType::Sword | ItemType::Pick | ItemType::Maul - => true, - _ => false, - } - } - - pub fn symbol(&self, subval: i64) -> chtype { - match self { - ItemType::MiscObject => { - match subval { - // Skeletons - 1|2|7|8|9|10|11|12 => 's', - - // Empty bottle - 4 => '!', - - // Broken garbage - 5|13 => '~', - - 99 => '(', - - _ => panic!(), - } - }.into(), - ItemType::Chest => { - match subval { - 5 => 'z', // Dead human body - _ => '&', - } - }.into(), - ItemType::MiscUsable => { - match subval { - 14 => '~', // Statue - 15 => 's', // Broken teeth - 16|17|18|19|20 => '~', // Metal cross - 21 => '!', // Bottle - 24 => '~', // Holy hand grenade - _ => panic!(), - } - }.into(), - ItemType::Jewelry => '*'.into(), - ItemType::Gem => '*'.into(), - ItemType::Bag => '~'.into(), - ItemType::WearableGem => '*'.into(), - - ItemType::SlingAmmo => '{'.into(), - ItemType::Bolt => '{'.into(), - ItemType::Arrow => '{'.into(), - ItemType::Spike => '~'.into(), - - ItemType::LightSource => '~'.into(), - - ItemType::RangedWeapon => '}'.into(), - ItemType::HaftedWeapon => '\\'.into(), - ItemType::PoleArm => '/'.into(), - ItemType::Dagger => { - match subval { - 40 => '\\', // Cat-O-Nine Tails - _ => '|', - } - }.into(), - ItemType::Sword => '|'.into(), - ItemType::Pick => '\\'.into(), - ItemType::Maul => '\\'.into(), - - ItemType::GemHelm => ']'.into(), - ItemType::Boots => ']'.into(), - ItemType::Gloves => ']'.into(), - ItemType::Cloak => '('.into(), - ItemType::Helm => ']'.into(), - ItemType::Shield => ')'.into(), - ItemType::HardArmor => '['.into(), - ItemType::SoftArmor => '('.into(), - ItemType::Bracers => { - match subval { - 7|264|271|272|273 => '*', // Fancy stuff - _ => ']', // Sturdy stuff - } - }.into(), - ItemType::Belt => { - match subval { - 10|11 => '*', // Fancy stuff - _ => '(', // Sturdy stuff - } - }.into(), - - ItemType::Amulet => { - match subval { - 268|269|270 => '*', // Fancy stuff - _ => '"', // Magic stuff - } - }.into(), - - ItemType::Ring => '='.into(), - - ItemType::Staff => '_'.into(), - - ItemType::Rod => '-'.into(), - - ItemType::Wand => '-'.into(), - ItemType::Scroll1 => '?'.into(), - ItemType::Scroll2 => '?'.into(), - - ItemType::Potion1 => '!'.into(), - ItemType::Potion2 => '!'.into(), - ItemType::FlaskOfOil => '!'.into(), - - ItemType::Food => { - match subval { - 2000 => 'R', // Rice-a-Roni - 4000 => 'J', // Jolly Green Jelly - _ => ',', - } - }.into(), - ItemType::JunkFood => ','.into(), - - ItemType::Chime => '%'.into(), - ItemType::Horn => '%'.into(), - - ItemType::MagicBook => '?'.into(), - ItemType::PrayerBook => '?'.into(), - ItemType::Instrument => '%'.into(), - ItemType::SongBook => '?'.into(), - - ItemType::LodgingAtInn => '.'.into(), - ItemType::Money => '$'.into(), - ItemType::UnseenTrap => '.'.into(), - ItemType::SeenTrap => { - match subval { - 1 => ' ', // Open pit - 6 => ';', // Loose rock - _ => '^', - } - }.into(), - ItemType::Rubble => ':'.into(), - ItemType::OpenDoor => '\''.into(), - ItemType::ClosedDoor => '+'.into(), - ItemType::UpStaircase => '<'.into(), - ItemType::DownStaircase => '>'.into(), - ItemType::SecretDoor => '#'.into(), - ItemType::EntranceToStore => { - match subval { - 101 => 'G' as chtype| A_BOLD, // General store - 102 => 'R' as chtype| A_BOLD, // Armory - 103 => 'W' as chtype| A_BOLD, // Weapon smith - 104 => 'T' as chtype| A_BOLD, // Temple - 105 => 'A' as chtype| A_BOLD, // Alchemy Shop - 106 => 'M' as chtype| A_BOLD, // Magic shop - 107 => 'I' as chtype| A_BOLD, // Inn - 109 => 'L' as chtype| A_BOLD, // Library - 110 => 'U' as chtype| A_BOLD, // Music shop - 113 => 'J' as chtype| A_BOLD, // Gem store - 116 => 'D' as chtype| A_BOLD, // Deli - 118 => '+' as chtype, // Black market - 108 => 'P' as chtype| A_BOLD, // Trading post - 111 => 'N' as chtype| A_BOLD, // Insurance shop - 112 => 'B' as chtype| A_BOLD, // Bank - 114 => 'X' as chtype| A_BOLD, // Money exchange - 115 => 'C' as chtype| A_BOLD, // Casino - 117 => 'Q' as chtype| A_BOLD, // Quest house - _ => '+' as chtype, - } - }, - ItemType::UpSteepStaircase => '<'.into(), - ItemType::DownSteepStaircase => '>'.into(), - ItemType::Whirlpool => panic!("whirlpool!"), - } - } + LodgingAtInn(item_template::LodgingAtInnTemplate), + Money(item_template::DungeonFeatureTemplate), + UnseenTrap(item_template::DungeonFeatureTemplate), + SeenTrap(item_template::DungeonFeatureTemplate), + Rubble(item_template::DungeonFeatureTemplate), + OpenDoor(item_template::DungeonFeatureTemplate), + ClosedDoor(item_template::DungeonFeatureTemplate), + UpStaircase(item_template::DungeonFeatureTemplate), + DownStaircase(item_template::DungeonFeatureTemplate), + SecretDoor(item_template::DungeonFeatureTemplate), + EntranceToStore(item_template::DungeonFeatureTemplate), + UpSteepStaircase(item_template::DungeonFeatureTemplate), + DownSteepStaircase(item_template::DungeonFeatureTemplate), + Whirlpool(item_template::DungeonFeatureTemplate), } impl From for ItemType { @@ -283,15 +96,17 @@ impl From for ItemType { 15 => ItemType::LightSource, - 20 => ItemType::RangedWeapon, - 21 => ItemType::HaftedWeapon, - 22 => ItemType::PoleArm, + 16 => ItemType::Bow, + 17 => ItemType::Crossbow, + 18 => ItemType::Sling, + + 21 => ItemType::Axe, + 22 => ItemType::Polearm, 23 => ItemType::Dagger, 24 => ItemType::Sword, 25 => ItemType::Pick, - 26 => ItemType::Maul, + 26 => ItemType::Mace, - 29 => ItemType::GemHelm, 30 => ItemType::Boots, 31 => ItemType::Gloves, 32 => ItemType::Cloak, @@ -308,14 +123,10 @@ impl From for ItemType { 55 => ItemType::Staff, - 60 => ItemType::Rod, - 65 => ItemType::Wand, - 70 => ItemType::Scroll1, - 71 => ItemType::Scroll2, + 70 => ItemType::Scroll, - 75 => ItemType::Potion1, - 76 => ItemType::Potion2, + 75 => ItemType::Potion, 77 => ItemType::FlaskOfOil, 80 => ItemType::Food, diff --git a/src/model/mod.rs b/src/model/mod.rs index dde5b406..707b64a5 100644 --- a/src/model/mod.rs +++ b/src/model/mod.rs @@ -7,7 +7,6 @@ pub use self::class::*; pub use self::currency::*; pub use self::dungeon_record::*; pub use self::gametime::*; -pub use self::identified_record::*; pub use self::inven_record::*; pub use self::inventory_item::*; pub use self::item::*; @@ -37,7 +36,6 @@ mod class_interop; mod currency; mod dungeon_record; mod gametime; -mod identified_record; mod inven_record; mod inventory_item; mod item; diff --git a/src/potions.c b/src/potions.c index 37b12edd..293cf01f 100644 --- a/src/potions.c +++ b/src/potions.c @@ -307,7 +307,7 @@ void quaff() { treas_rec *item_ptr; char trash_char; boolean redraw, ident; - obj_set stuff_to_drink = {potion1, potion2, 0}; + obj_set stuff_to_drink = {potion, 0}; reset_flag = true; @@ -328,28 +328,11 @@ void quaff() { for (; q1 > 0 || q2 > 0;) { i6 = bit_pos64(&q2, &q1) + 1; - /* - * It looks like potion2 was created - *before flags2 was - * added to the treasure type, now we - *can fit all the - * potion effects into the pair of - *flags. - * - * The += 31 should be 64 now, I am - *leaving it at 31 so - * that old characters do not get - *confused. - */ - if (item_ptr->data.tval == potion2) { - i6 += 31; - } - q__potion_effect(i6, &ident); } /* end for */ if (ident) { - identify(&(item_ptr->data)); + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); } if (item_ptr->data.flags != 0) { diff --git a/src/quest.c b/src/quest.c index e2ff5322..448487d1 100644 --- a/src/quest.c +++ b/src/quest.c @@ -77,7 +77,7 @@ void q__reward_item(long target) { obj_set wand_set = {staff, wand, 0}; obj_set weapon_set = { - bow_crossbow_or_sling, hafted_weapon, pole_arm, dagger, sword, maul, 0}; + bow, crossbow, sling, hafted_weapon, pole_arm, dagger, sword, maul, 0}; obj_set misc1_set = {bracers, belt, amulet, ring, 0}; obj_set misc2_set = {valuable_gems, bag_or_sack, valuable_gems_wear, chime, horn, 0}; @@ -116,11 +116,10 @@ void q__reward_item(long target) { } } - unquote(rewards[i2].name); - known1(rewards[i2].name); - known2(rewards[i2].name); + set_type_identified(rewards[i2].tval, rewards[i2].subval, true); + rewards[i2].identified = true; inven_temp.data = rewards[i2]; - objdes(reward_names[i2], &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, reward_names[i2]); } pusht(i1); diff --git a/src/routines.h b/src/routines.h index 30a6ec67..7eab1463 100644 --- a/src/routines.h +++ b/src/routines.h @@ -8,6 +8,11 @@ #include "types.h" /* START - FROM RUST */ +uint8_t is_type_identified(uint8_t item_type, int64_t subval); +void set_type_identified(uint8_t item_type, int64_t subval, uint8_t is_identified); + +void C_item_name_generate_name(treasure_type *item, char result[70]); + boolean C_save_character(); boolean C_load_character(); void C_delete_character(); @@ -60,16 +65,6 @@ extern void make_tomb(char dstr[][82]); extern void write_tomb(char dstr[][82]); extern void print_dead_character(); -/* { DESC.PAS } */ -extern void rantitle(char *title); /* : varying[a] of char); */ -extern void known1(char *object_str); /* : varying[a] of char); */ -extern void known2(char *object_str); /* : varying[a] of char); */ -extern void unquote(char *object_str); /* : varying[a] of char); */ -extern void identify(treasure_type *item); -extern void objdes(char *out_val, /*: varying[a] of char; */ - treas_rec *ptr, /* : treas_ptr; */ - boolean pref); /* : boolean); */ - /* { DUNGEON.PAS } */ extern void move_rec(long y1, long x1, long y2, long x2); extern void change_speed(long num); @@ -427,7 +422,6 @@ extern void petrify(long amt); extern void compact_objects(); extern void popt(long *x); extern void pusht(long x); -extern void magic_treasure(long x, long level, boolean forceit); extern void place_trap(long y, long x, long typ, long subval); extern void place_rubble(long y, long x); extern void place_open_door(long y, long x); diff --git a/src/save/identified.rs b/src/save/identified.rs index 226f0351..70b05fd0 100644 --- a/src/save/identified.rs +++ b/src/save/identified.rs @@ -1,21 +1,12 @@ -use libc; - -use constants; use debug; -use model::IdentifiedRecord; - -extern "C" { - static mut object_ident: [libc::uint8_t; constants::MAX_OBJECTS + 1]; -} +use identification; -pub fn record() -> IdentifiedRecord { - IdentifiedRecord { - list: unsafe { object_ident }.to_owned(), - } +pub fn record() -> identification::Data { + identification::save() } -pub fn set_record(record: IdentifiedRecord) { +pub fn set_record(record: identification::Data) { debug::enter("identified::set_record"); - unsafe { object_ident = record.list }; + identification::load(record); debug::leave("identified::set_record"); } diff --git a/src/save/save.rs b/src/save/save.rs index c30d4c22..374f7529 100644 --- a/src/save/save.rs +++ b/src/save/save.rs @@ -12,9 +12,10 @@ use ncurses; use save; use term; use model::{ - DungeonRecord, IdentifiedRecord, InventoryItem, Item, MonsterRecord, + DungeonRecord, InventoryItem, Item, MonsterRecord, PlayerRecord, TownRecord }; +use identification; use player; @@ -25,7 +26,7 @@ struct SaveRecord { equipment: Vec, town: TownRecord, dungeon: DungeonRecord, - identified: IdentifiedRecord, + identification_data: identification::Data, monsters: MonsterRecord, } diff --git a/src/scrolls.c b/src/scrolls.c index 94b571bf..4273de72 100644 --- a/src/scrolls.c +++ b/src/scrolls.c @@ -37,7 +37,7 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, /* with equipment[Equipment_primary]. do; */ if (equipment[Equipment_primary].tval > 0) { inven_temp.data = equipment[Equipment_primary]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "Your %s glows faintly!", out_val); msg_print(out_val2); if (enchant(&(equipment[Equipment_primary].tohit))) { @@ -55,7 +55,7 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, /* with equipment[Equipment_primary]. do; */ if (equipment[Equipment_primary].tval > 0) { inven_temp.data = equipment[Equipment_primary]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "Your %s glows faintly!", out_val); msg_print(out_val2); if (enchant(&(equipment[Equipment_primary].todam))) { @@ -131,7 +131,7 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, if (i4 > 0) { /* with equipment[i4]. do; */ inven_temp.data = equipment[i4]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "Your %s glows faintly!", out_val); msg_print(out_val2); if (enchant(&(equipment[i4].toac))) { @@ -145,7 +145,8 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, break; case 4: /*{ Identify }*/ - identify(&(item_ptr->data)); + item_ptr->data.identified = true; + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); msg_print("This is an identify scroll"); msg_print(" "); if (ident_spell()) { @@ -259,7 +260,8 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, break; case 25: /*{ Recharge Item }*/ - identify(&(item_ptr->data)); + item_ptr->data.identified = true; + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); msg_print("This is a Recharge-Item scroll."); msg_print(" "); if (recharge(60)) { @@ -299,7 +301,7 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, /* with equipment[Equipment_primary]. do; */ if (equipment[Equipment_primary].tval > 0) { inven_temp.data = equipment[Equipment_primary]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "Your %s glows brightly!", out_val); msg_print(out_val2); flag = false; @@ -330,7 +332,7 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, /* with equipment[Equipment_primary]. do; */ if (equipment[Equipment_primary].tval > 0) { inven_temp.data = equipment[Equipment_primary]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "Your %s glows black, then fades.", out_val); msg_print(out_val2); equipment[Equipment_primary].tohit = -randint(5) - randint(5); @@ -375,7 +377,7 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, if (i3 > 0) { /* with equipment[i3]. do; */ inven_temp.data = equipment[i3]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "Your %s glows brightly!", out_val); msg_print(out_val2); flag = false; @@ -431,7 +433,7 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, if (i3 > 0) { /* with equipment[i3]. do; */ inven_temp.data = equipment[i3]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "Your %s glows black, then fades.", out_val); msg_print(out_val2); equipment[i3].flags = Cursed_worn_bit; @@ -550,106 +552,92 @@ void rs__scroll_effect(long effect, boolean *idented, boolean *first, void read_scroll() { /*{ Scrolls for the reading -RAK- }*/ - unsigned long q1, q2; - long i3, i5; + + boolean first = true; + reset_flag = true; + + if (inven_ctr <= 0) { + msg_print("But you are not carrying anything."); + return; + } + treas_rec *i2; + long i3; + obj_set stuff_to_read = {Scroll, 0}; + if (!find_range(stuff_to_read, false, &i2, &i3)) { + msg_print("You are not carrying any scrolls."); + return; + } + + if (player_flags.blind > 0) { + msg_print("You can't see to read the scroll."); + return; + } + + if (no_light()) { + msg_print("You have no light to read by."); + return; + } + + if (player_flags.confused > 0) { + msg_print("The text seems to swim about the page!"); + msg_print("You are too confused to read..."); + return; + } + treas_rec *item_ptr; + boolean redraw = false; char trash_char; - boolean redraw, ident, first; - obj_set stuff_to_read = {scroll1, scroll2, 0}; - - first = true; - reset_flag = true; + if (!get_item(&item_ptr, "Read which scroll?", &redraw, i3, &trash_char, false, false)) { + if (redraw) { + draw_cave(); + } + return; + } - if (inven_ctr > 0) { - if (find_range(stuff_to_read, false, &i2, &i3)) { - if (player_flags.blind > 0) { - msg_print("You can't see to read the scroll."); - } else if (no_light()) { - msg_print("You have no light to read by."); - } else if (player_flags.confused > 0) { - msg_print("The text seems to swim about the page!"); - msg_print("You are too confused to read..."); - } else { - redraw = false; - if (get_item(&item_ptr, "Read which scroll?", &redraw, i3, &trash_char, - false, false)) { - /* with item_ptr->data. do; */ - if (redraw) { - draw_cave(); - } - reset_flag = false; - q1 = item_ptr->data.flags; - q2 = item_ptr->data.flags2; - ident = false; - for (; q1 > 0 || q2 > 0;) { - i5 = bit_pos64(&q2, &q1) + 1; - - /* - * It looks like scroll2 was - *created before flags2 was - * added to the treasure type, - *now we can fit all the - * potion effects into the pair - *of flags. - * - * The += 31 should be 64 now, I - *am leaving it at 31 so - * that old characters do not - *get confused. - */ - if (item_ptr->data.tval == scroll2) { - i5 += 31; - } - if (first) { - if (!(i5 == 4 || i5 == 25 || i5 == 42)) { - /* the above - * are: - * identify, - * recharge - * item, wishing - */ - msg_print("As you " - "read the " - "scroll it " - "vanishes" - "."); - first = false; - } - - rs__scroll_effect(i5, &ident, &first, item_ptr); - } + if (redraw) { + draw_cave(); + } + reset_flag = false; + unsigned long q1 = item_ptr->data.flags; + unsigned long q2 = item_ptr->data.flags2; + boolean ident = false; + for (; q1 > 0 || q2 > 0;) { + long i5 = bit_pos64(&q2, &q1) + 1; + + if (first) { + if (!(i5 == 4 || i5 == 25 || i5 == 42)) { + /* the above are: + * identify, + * recharge item, + * wishing + */ + msg_print("As you read the scroll it vanishes."); + first = false; } - if (!(reset_flag)) { - if (ident) { - identify(&(item_ptr->data)); - } - if (!first) { - desc_remain(item_ptr); - inven_destroy(item_ptr); - prt_stat_block(); + rs__scroll_effect(i5, &ident, &first, item_ptr); + } + } - if (item_ptr->data.flags != 0) { - /* with py.misc - */ - /* do; */ - C_player_add_exp((item_ptr->data.level / (float)player_lev) + - .5); - prt_stat_block(); - } - } - } - } else { - if (redraw) { - draw_cave(); + if (!(reset_flag)) { + if (ident) { + item_ptr->data.identified = true; + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); + } + if (!first) { + desc_remain(item_ptr); + inven_destroy(item_ptr); + prt_stat_block(); + + if (item_ptr->data.flags != 0) { + /* with py.misc + */ + /* do; */ + C_player_add_exp((item_ptr->data.level / (float)player_lev) + + .5); + prt_stat_block(); } - } } - } else { - msg_print("You are not carrying any scrolls."); - } - } else { - msg_print("But you are not carrying anything."); } } diff --git a/src/spells.c b/src/spells.c index 9141e417..e9b8ad01 100644 --- a/src/spells.c +++ b/src/spells.c @@ -26,8 +26,7 @@ #define OBJ_BOLT_RANGE 18 /*{ Maximum range of bolts and balls } */ static const treasure_type scare_monster = /* { Special trap } */ - {"a strange rune", - seen_trap, + {seen_trap, 0x00000000, 0x00000000, 0, @@ -44,9 +43,9 @@ static const treasure_type scare_monster = /* { Special trap } */ 0}; /* used in get_flags, and other places if I needed them */ static obj_set null_obj_set = {0, 0}; -static obj_set destroyed_by_lightning = {ring, rod, wand, 0}; +static obj_set destroyed_by_lightning = {ring, wand, 0}; static obj_set destroyed_by_acid = {arrow, - bow_crossbow_or_sling, + bow, crossbow, sling, hafted_weapon, pole_arm, gem_helm, @@ -58,15 +57,14 @@ static obj_set destroyed_by_acid = {arrow, hard_armor, soft_armor, staff, - scroll1, - scroll2, + Scroll, Food, open_door, closed_door, 0}; -static obj_set destroyed_by_cold = {potion1, potion2, 0}; +static obj_set destroyed_by_cold = {potion, 0}; static obj_set destroyed_by_fire = {arrow, - bow_crossbow_or_sling, + bow, crossbow, sling, hafted_weapon, pole_arm, boots, @@ -74,18 +72,16 @@ static obj_set destroyed_by_fire = {arrow, cloak, soft_armor, staff, - scroll1, - scroll2, - potion1, - potion2, + Scroll, + potion, Food, open_door, closed_door, 0}; -static obj_set destroyed_by_petrify = {boots, soft_armor, potion1, - potion2, Food, 0}; -static obj_set destroyed_by_sunray = {cloak, scroll1, scroll2, - potion1, potion2, 0}; +static obj_set destroyed_by_petrify = {boots, soft_armor, potion, + Food, 0}; +static obj_set destroyed_by_sunray = {cloak, Scroll, + potion, 0}; static void get_flags(enum spell_effect_t typ, long *weapon_type, long *harm_type, obj_set **destroy) { @@ -1085,9 +1081,6 @@ boolean detect_trap() { change_trap(i1, i2); cave[i1][i2].fm = true; flag = true; - } else if (t_list[cave[i1][i2].tptr].tval == chest) { - /* with t_list[tptr] do; */ - known2(t_list[cave[i1][i2].tptr].name); } } } @@ -1200,7 +1193,7 @@ boolean ident_spell() { /*{ Identify an object -RAK- }*/ treas_rec *item_ptr; - char out_val[82]; + char out_val[70]; char trash_char; treas_rec *ptr; long count = 0; @@ -1212,7 +1205,7 @@ boolean ident_spell() { /* only show things that need to be identified */ change_all_ok_stats(false, false); for (ptr = inventory_list; ptr != NULL; ptr = ptr->next) { - if (strchr(ptr->data.name, '^') || strchr(ptr->data.name, '|')) { + if (!ptr->data.identified) { ptr->ok = true; count++; } @@ -1226,9 +1219,9 @@ boolean ident_spell() { if (get_item(&item_ptr, "Item you wish identified?", &redraw, count, &trash_char, false, false)) { /* with item_ptr->data. do; */ - identify(&(item_ptr->data)); - known2(item_ptr->data.name); - objdes(out_val, item_ptr, true); + item_ptr->data.identified = true; + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); + C_item_name_generate_name(&item_ptr->data, out_val); msg_print(out_val); return_value = true; @@ -1469,7 +1462,7 @@ boolean door_creation() { } cave[i1][i2].fopen = false; cave[i1][i2].tptr = i3; - t_list[i3] = door_list[2]; + t_list[i3] = door_secret; if (test_light(i1, i2)) { lite_spot(i1, i2); } @@ -1538,7 +1531,7 @@ boolean protect_evil() { /*//////////////////////////////////////////////////////////////////// */ /*//////////////////////////////////////////////////////////////////// */ boolean recharge(long num) { - /*{ Recharge a wand, staff, or rod. Sometimes the item breaks. -RAK-}*/ + /*{ Recharge a wand or staff. Sometimes the item breaks. -RAK-}*/ treas_rec *item_ptr; boolean redraw = false; @@ -1547,7 +1540,7 @@ boolean recharge(long num) { */ /* that */ /* uses charges. 2/15/00 JEB */ - obj_set batteries_not_included = {valuable_gems, staff, rod, wand, + obj_set batteries_not_included = {valuable_gems, staff, wand, chime, horn, 0}; boolean return_value = false; @@ -1564,9 +1557,7 @@ boolean recharge(long num) { return_value = true; num = num / (item_ptr->data.level + 2); item_ptr->data.p1 += 2 + randint(num); - if (strchr(item_ptr->data.name, '^') != NULL) { - insert_str(item_ptr->data.name, " (%P1", "^ (%P1"); - } + item_ptr->data.identified = true; } } else if ((item_ptr->data.tval == lamp_or_torch) && (item_ptr->data.subval == 17)) { @@ -1578,9 +1569,7 @@ boolean recharge(long num) { return_value = true; num *= 100; item_ptr->data.p1 += num / 3 + randint(num); - if (strchr(item_ptr->data.name, '^') != NULL) { - insert_str(item_ptr->data.name, " (%P1", "^ (%P1"); - } + item_ptr->data.identified = true; } } else if ((item_ptr->data.tval == lamp_or_torch) && (item_ptr->data.subval == 15)) { @@ -1592,9 +1581,7 @@ boolean recharge(long num) { return_value = true; num *= 80; item_ptr->data.p1 += num / 3 + randint(num); - if (strchr(item_ptr->data.name, '^') != NULL) { - insert_str(item_ptr->data.name, " (%P1", "^ (%P1"); - } + item_ptr->data.identified = true; } } } @@ -2305,7 +2292,7 @@ boolean wall_to_mud(long dir, long y, long x) { if (panel_contains(y, x)) { if (test_light(y, x)) { inven_temp.data = t_list[cave[y][x].tptr]; - objdes(out_val, &inven_temp, false); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out_val2, "The %s turns into mud.", out_val); msg_print(out_val2); return_value = true; @@ -2472,7 +2459,6 @@ boolean disarm_all(long dir, long y, long x) { /*{ Disarms all traps/chests in a given direction -RAK- }*/ long oldy, oldx, tval; - char *achar; boolean flag = false; do { @@ -2497,12 +2483,7 @@ boolean disarm_all(long dir, long y, long x) { t_list[cave[y][x].tptr].flags &= 0xFFFFFE0F; /* detrap */ t_list[cave[y][x].tptr].flags &= 0xFFFFFFFE; /* unlock */ flag = true; - achar = strstr(t_list[cave[y][x].tptr].name, " ("); - if (achar != NULL) { - *achar = 0; - } - strcat(t_list[cave[y][x].tptr].name, " (Unlocked)"); - known2(t_list[cave[y][x].tptr].name); + t_list[cave[y][x].tptr].identified = true; } } } @@ -2723,15 +2704,11 @@ boolean am_i_dumb() { return player_lev < randint(randint(50)); } boolean lore_spell() { /*{ Give name for most items in inventory -Cap'n- }*/ - treas_rec *thingy; - - thingy = inventory_list; - for (; thingy != NULL;) { + for (treas_rec *thingy = inventory_list; thingy != NULL; thingy = thingy->next) { if (!am_i_dumb()) { - identify(&(thingy->data)); - known2(thingy->data.name); + set_type_identified(thingy->data.tval, thingy->data.subval, true); + thingy->data.identified = true; } - thingy = thingy->next; } return true; diff --git a/src/staffs.c b/src/staffs.c index 8bd7b508..d9b5dec5 100644 --- a/src/staffs.c +++ b/src/staffs.c @@ -199,8 +199,7 @@ void use_staff() { } if (randint(chance) < USE_DEVICE) { - msg_print("You failed to use the staff " - "properly."); + msg_print("You failed to use the staff properly."); } else if (item_ptr->data.p1 > 0) { i1 = item_ptr->data.flags; ident = false; @@ -210,7 +209,7 @@ void use_staff() { us__staff_effect(i4, &ident); } - identify(&(item_ptr->data)); + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); if (ident) { if (item_ptr->data.flags != 0) { /* with player_do; */ diff --git a/src/stores.c b/src/stores.c index 818b856e..081d3bbd 100644 --- a/src/stores.c +++ b/src/stores.c @@ -371,9 +371,7 @@ static void __add_item_to_store(enum store_t store_num) { default: return; // Should panic } - unquote(t_list[cur_pos].name); - known1(t_list[cur_pos].name); - known2(t_list[cur_pos].name); + t_list[cur_pos].identified = true; // TODO: Stop using inven_temp inven_temp.data = t_list[cur_pos]; @@ -571,7 +569,7 @@ static void __store_print_inventory(enum store_t store_type, long start) { inven_temp.data.number = 1; } char out_val1[82]; - objdes(out_val1, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, out_val1); char out_val2[85]; sprintf(out_val2, "%c) %s", (97 + (int)i), out_val1); prt(out_val2, i + 6, 1); @@ -1338,7 +1336,7 @@ static boolean __store_purchase(enum store_t store_type, long *cur_top, __remove_item_from_store(store_type, selected_item, true); treas_rec *item_new = inven_carry(); char out_val[82]; - objdes(out_val, item_new, true); + C_item_name_generate_name(&item_new->data, out_val); char out2[100]; sprintf(out2, "You have %s", out_val); msg_print(out2); @@ -1552,7 +1550,7 @@ static boolean __store_sell(enum store_t store_type, long cur_top, char out_val[82]; char out2[100]; - objdes(out_val, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, out_val); sprintf(out2, "Selling %s", out_val); msg_print(out2); msg_print(" "); @@ -1790,10 +1788,7 @@ void store_carry(enum store_t store_num, long *ipos) { // TODO: Stop using inven_temp *ipos = 0; - identify(&(inven_temp.data)); - unquote(inven_temp.data.name); - known1(inven_temp.data.name); - known2(inven_temp.data.name); + inven_temp.data.identified = true; long item_base_price = __calc_purchase_price(store_num, &inven_temp.data); long max_price = __store_max_inflated_price(store_num, item_base_price); @@ -1840,7 +1835,9 @@ long item_value(treasure_type const *const item) { switch (item->tval) { // Weapons and armor - case bow_crossbow_or_sling: + case bow: + case crossbow: + case sling: case hafted_weapon: case pole_arm: case sword: @@ -1855,12 +1852,14 @@ long item_value(treasure_type const *const item) { case hard_armor: case soft_armor: - if (strstr(item->name, "^") != NULL) { + if (!item->identified) { return_value *= item->number; } else { switch (item->tval) { - case bow_crossbow_or_sling: + case bow: + case crossbow: + case sling: case hafted_weapon: case pole_arm: case sword: @@ -1897,7 +1896,7 @@ long item_value(treasure_type const *const item) { case arrow: case spike: - if (strstr(item->name, "^") != NULL) { + if (!item->identified) { return_value *= (item->number); } else { if (item->tohit < 0) { @@ -1915,21 +1914,17 @@ long item_value(treasure_type const *const item) { break; // Potions, Scrolls, and Food - case scroll1: - case scroll2: - case potion1: - case potion2: + case Scroll: + case potion: case Food: - if (strstr(item->name, "|") != NULL) { + if (!item->identified) { switch (item->tval) { - case scroll1: - case scroll2: + case Scroll: return_value = 20; break; - case potion1: - case potion2: + case potion: return_value = 20; break; @@ -1944,7 +1939,7 @@ long item_value(treasure_type const *const item) { case amulet: case ring: - if (strstr(item->name, "|") != NULL) { + if (!is_type_identified(item->tval, item->subval)) { switch (item->tval) { case amulet: return_value = 45; @@ -1953,7 +1948,7 @@ long item_value(treasure_type const *const item) { return_value = 45; break; } - } else if (strstr(item->name, "^") != NULL) { + } else if (!item->identified) { return_value = (item->cost > 0) ? (item->cost / GOLD_VALUE) : 0; } else { return_value = @@ -1969,7 +1964,7 @@ long item_value(treasure_type const *const item) { case chime: case horn: - if (strstr(item->name, "|") != NULL) { + if (!is_type_identified(item->tval, item->subval)) { switch (item->tval) { case chime: return_value = 50; @@ -1978,30 +1973,26 @@ long item_value(treasure_type const *const item) { return_value = 80; break; } - } else if (strstr(item->name, "^") == NULL) { + } else if (!item->identified) { return_value = ((item->cost / GOLD_VALUE) + trunc(item->cost / COST_ADJ / 20.0) * (item->p1)); } break; - // Wands rods, and staffs + // Wands and staffs case staff: - case rod: case wand: - if (strstr(item->name, "|") != NULL) { + if (!is_type_identified(item->tval, item->subval)) { switch (item->tval) { case staff: return_value = 70; break; - case rod: - return_value = 60; - break; case wand: return_value = 50; break; } - } else if (strstr(item->name, "^") == NULL) { + } else if (!item->identified) { return_value = ((item->cost / GOLD_VALUE) + trunc(item->cost / COST_ADJ / 20.0) * (item->p1)); } @@ -2011,7 +2002,7 @@ long item_value(treasure_type const *const item) { case valuable_jewelry: case valuable_gems: - if (strstr(item->name, "|") != NULL) { + if (!is_type_identified(item->tval, item->subval)) { switch (item->tval) { case valuable_jewelry: return_value = 20; @@ -2020,7 +2011,7 @@ long item_value(treasure_type const *const item) { return_value = 20; break; } - } else if (strstr(item->name, "^") == NULL) { + } else if (!item->identified) { return_value = (item->cost / GOLD_VALUE); } break; @@ -2087,7 +2078,7 @@ boolean check_store_hours(enum store_t store_type, long store_visual) { break; } char name[134]; - strcpy(name, store_door[store_type].name); + C_item_name_generate_name(&store_door[store_type], name); insert_str(name, "the entrance to the ", ""); char out_val[300]; sprintf(out_val, "Sorry, the %s is closed for the %s", name, time); diff --git a/src/trade.c b/src/trade.c index 188dbc7a..5df7925c 100644 --- a/src/trade.c +++ b/src/trade.c @@ -363,7 +363,7 @@ void tp__display_inv(pinven_ptr start, pinven_ptr *inv, pinven_ptr *blegga, char out_val2[85]; cur_display[count] = start; inven_temp.data = start->data.fsr.object; - objdes(out_val1, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, out_val1); sprintf(out_val2, "%c) %s", (char)(96 + count), out_val1); prt(out_val2, count + 5, 1); sprintf(out_val2, "%ld", start->data.fsr.best_bid); @@ -549,7 +549,7 @@ void tpd__player_wins_bid(pinven_ptr *item, pinven_ptr *inv, if (inven_check_num() && inven_check_weight()) { temp_ptr = inven_carry(); msg_print("You are now the proud owner of"); - objdes(out_val1, temp_ptr, true); + C_item_name_generate_name(&temp_ptr->data, out_val1); sprintf(out_val2, "%s.", out_val1); msg_print(out_val2); tp__send_money(&((*item)->data.fsr.seller), @@ -700,7 +700,7 @@ void tp__dump(char filename[82], pinven_ptr *inv) { sprintf(out_val, "%ld", item->data.fsr.time); fprintf(dump, " time: %s\n", out_val); inven_temp.data = item->data.fsr.object; - objdes(out_val, &inven_temp, true); + C_item_name_generate_name(&inven_temp.data, out_val); fprintf(dump, " object: %s\n", out_val); fprintf(dump, " seller: %s/%ld\n", item->data.fsr.seller.username, item->data.fsr.seller.claim_check); @@ -818,8 +818,7 @@ void tp__sell(pinven_ptr *inv, pinven_ptr *cur_top, pinven_ptr *blegga, } } - if ((strstr(item_ptr->data.name, "|") != NULL) || - (strstr(item_ptr->data.name, "^") != NULL)) { + if (!item_ptr->data.identified) { strcpy(response, "I can't sell that! Identify it first!"); } else if (wgt != 0) { strcpy(response, "Hey that bag is full of items! Empty it first."); diff --git a/src/traps.c b/src/traps.c index 3852d888..6b1f574e 100644 --- a/src/traps.c +++ b/src/traps.c @@ -25,96 +25,96 @@ /* { Traps are just Nasty treasures... } */ static treasure_type trap_lista[MAX_TRAPA + 1] = { - {"bogus trap a", seen_trap, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, 0, "2d6", -50, 0}, - {"an open pit", seen_trap, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, 0, "2d6", -50, 0}, - {"an arrow trap", unseen_trap, 0x00000000, 0x00000000, 0, 0, 2, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 2, 0, 0, 0, 0, 0, 0, "1d8", 0, 0}, - {"a covered pit", unseen_trap, 0x00000000, 0x00000000, 0, 0, 3, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 3, 0, 0, 0, 0, 0, 0, "2d6", 0, 0}, - {"a trap door", unseen_trap, 0x00000000, 0x00000000, 0, 0, 4, 0, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 4, 0, 0, 0, 0, 0, 0, "2d8", 0, 0}, - {"a gas trap", unseen_trap, 0x00000000, 0x00000000, 0, 0, 5, 0, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 5, 0, 0, 0, 0, 0, 0, "1d4", 0, 0}, - {"a loose rock", unseen_trap, 0x00000000, 0x00000000, 0, 0, 6, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 6, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"a dart trap", unseen_trap, 0x00000000, 0x00000000, 0, 0, 7, 0, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 7, 0, 0, 0, 0, 0, 0, "1d4", 0, 0}, - {"a strange rune", unseen_trap, 0x00000000, 0x00000000, 0, 0, 8, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 8, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"some loose rock", unseen_trap, 0x00000000, 0x00000000, 0, 0, 9, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 9, 0, 0, 0, 0, 0, 0, "2d6", 0, 0}, - {"a gas trap", unseen_trap, 0x00000000, 0x00000000, 0, 0, 10, 0, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 10, 0, 0, 0, 0, 0, 0, "1d4", 0, 0}, - {"a strange rune", unseen_trap, 0x00000000, 0x00000000, 0, 0, 11, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 11, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"a blackened spot", unseen_trap, 0x00000000, 0x00000000, 0, 0, 12, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 12, 0, 0, 0, 0, 0, 0, "4d6", 0, 0}, - {"some corroded rock", unseen_trap, 0x00000000, 0x00000000, 0, 0, 13, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 13, 0, 0, 0, 0, 0, 0, "4d6", 0, 0}, - {"a gas trap", unseen_trap, 0x00000000, 0x00000000, 0, 0, 14, 0, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 0, 0, 14, 0, 0, 0, 0, 0, 0, "2d6", 0, 0}, - {"a gas trap", unseen_trap, 0x00000000, 0x00000000, 5, 0, 15, 0, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 5, 0, 15, 0, 0, 0, 0, 0, 0, "1d4", 10, 0}, - {"a gas trap", unseen_trap, 0x00000000, 0x00000000, 5, 0, 16, 0, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 5, 0, 16, 0, 0, 0, 0, 0, 0, "1d8", 5, 0}, - {"a dart trap", unseen_trap, 0x00000000, 0x00000000, 5, 0, 17, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 5, 0, 17, 0, 0, 0, 0, 0, 0, "1d8", 10, 0}, - {"a dart trap", unseen_trap, 0x00000000, 0x00000000, 5, 0, 18, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 5, 0, 18, 0, 0, 0, 0, 0, 0, "1d8", 10, 0}, - {"a chute", unseen_trap, 0x00000000, 0x00000000, 5, 0, 20, 0, 0, 0, 0, 0, 0, + {unseen_trap, 0x00000000, 0x00000000, 5, 0, 20, 0, 0, 0, 0, 0, 0, "4d8", 20, 0}}; /* { Traps: Level represents the difficulty of disarming; } */ /* { and P1 represents the experienced gained when disarmed} */ static treasure_type trap_listb[MAX_TRAPB + 1] = { - {"bogus trap b", seen_trap, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, 0, "2d6", -50, 0}, - {"an open pit", seen_trap, 0x00000000, 0x00000000, 1, 0, 1, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 1, 0, 1, 0, 0, 0, 0, 0, 0, "2d6", -50, 0}, - {"an arrow trap", seen_trap, 0x00000000, 0x00000000, 3, 0, 2, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 3, 0, 2, 0, 0, 0, 0, 0, 0, "1d8", -10, 0}, - {"a covered pit", seen_trap, 0x00000000, 0x00000000, 2, 0, 3, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 2, 0, 3, 0, 0, 0, 0, 0, 0, "2d6", -40, 0}, - {"a trap door", seen_trap, 0x00000000, 0x00000000, 5, 0, 4, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 4, 0, 0, 0, 0, 0, 0, "2d8", -25, 0}, - {"a gas trap", seen_trap, 0x00000000, 0x00000000, 3, 0, 5, 0, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 3, 0, 5, 0, 0, 0, 0, 0, 0, "1d4", 5, 0}, - {"a loose rock", seen_trap, 0x00000000, 0x00000000, 0, 0, 6, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 0, 0, 6, 0, 0, 0, 0, 0, 0, "0d0", -90, 0}, - {"a dart trap", seen_trap, 0x00000000, 0x00000000, 5, 0, 7, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 7, 0, 0, 0, 0, 0, 0, "1d4", 10, 0}, - {"a strange rune", seen_trap, 0x00000000, 0x00000000, 5, 0, 8, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 8, 0, 0, 0, 0, 0, 0, "0d0", -10, 0}, - {"some loose rock", seen_trap, 0x00000000, 0x00000000, 5, 0, 9, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 9, 0, 0, 0, 0, 0, 0, "2d6", -10, 0}, - {"a gas trap", seen_trap, 0x00000000, 0x00000000, 10, 0, 10, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 10, 0, 10, 0, 0, 0, 0, 0, 0, "1d4", 5, 0}, - {"a strange rune", seen_trap, 0x00000000, 0x00000000, 5, 0, 11, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 11, 0, 0, 0, 0, 0, 0, "0d0", -10, 0}, - {"a blackened spot", seen_trap, 0x00000000, 0x00000000, 10, 0, 12, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 10, 0, 12, 0, 0, 0, 0, 0, 0, "4d6", 10, 0}, - {"some corroded rock", seen_trap, 0x00000000, 0x00000000, 10, 0, 13, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 10, 0, 13, 0, 0, 0, 0, 0, 0, "4d6", 10, 0}, - {"a gas trap", seen_trap, 0x00000000, 0x00000000, 5, 0, 14, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 14, 0, 0, 0, 0, 0, 0, "2d6", 5, 0}, - {"a gas trap", seen_trap, 0x00000000, 0x00000000, 5, 0, 15, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 15, 0, 0, 0, 0, 0, 0, "1d4", 10, 0}, - {"a gas trap", seen_trap, 0x00000000, 0x00000000, 5, 0, 16, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 16, 0, 0, 0, 0, 0, 0, "1d8", 5, 0}, - {"a dart trap", seen_trap, 0x00000000, 0x00000000, 5, 0, 17, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 17, 0, 0, 0, 0, 0, 0, "1d8", 10, 0}, - {"a dart trap", seen_trap, 0x00000000, 0x00000000, 5, 0, 18, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 18, 0, 0, 0, 0, 0, 0, "1d8", 10, 0}, /* { Special case, see DOOR_LIST below (subvals must agree) } */ - {"a closed door", closed_door, 0x00000000, 0x00000000, 0, 0, 19, 0, 0, 0, 0, + {closed_door, 0x00000000, 0x00000000, 0, 0, 19, 0, 0, 0, 0, 0, 0, "1d1", 0, 0}, - {"a chute", seen_trap, 0x00000000, 0x00000000, 5, 0, 20, 0, 0, 0, 0, 0, 0, + {seen_trap, 0x00000000, 0x00000000, 5, 0, 20, 0, 0, 0, 0, 0, 0, "4d8", 20, 0}}; static treasure_type some_rubble = { - "some rubble", rubble, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, 0, + rubble, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}; /*//////////////////////////////////////////////////////////////////// */ diff --git a/src/treasures.c b/src/treasures.c index 61f86697..3615e9f2 100644 --- a/src/treasures.c +++ b/src/treasures.c @@ -20,26 +20,6 @@ long t_level[MAX_OBJ_LEVEL + 1]; -char const *syllables[MAX_SYLLABLES] = { - "a", "ab", "ag", "aks", "ala", "an", "ankh", "app", "arg", - "arze", "ash", "aus", "ban", "bar", "bat", "bek", "bie", "bin", - "bit", "bjor", "blu", "brd", "bu", "byt", "comp", "con", "cos", - "cre", "dalf", "dan", "den", "doe", "dok", "eep", "el", "eng", - "er", "ere", "erk", "esh", "evs", "fa", "fid", "for", "fri", - "fu", "gan", "gar", "glen", "gop", "gre", "ha", "he", "hyd", - "i", "ing", "ion", "ip", "ish", "it", "ite", "iv", "jo", - "kho", "kli", "klis", "la", "lech", "man", "mar", "me", "mi", - "mic", "mik", "mon", "mung", "mur", "naed", "neg", "nep", "ner", - "nes", "nis", "nih", "nin", "o", "od", "ood", "ook", "oook", - "org", "orn", "ox", "oxy", "pay", "pet", "ple", "plu", "po", - "pot", "prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", - "rol", "sa", "san", "sat", "see", "sef", "seh", "shu", "si", - "snd", "sne", "snik", "sno", "so", "sol", "spam", "sri", "sta", - "sun", "ta", "taf", "tem", "ther", "ti", "tox", "trol", "tue", - "turs", "u", "ulk", "um", "un", "uni", "ur", "val", "viv", - "vly", "vom", "wah", "wed", "werg", "wex", "whon", "wlf", "x", - "yerg", "yp", "zun"}; - static const float obj_std_adj = 1.25; // Adjust STD per level static const long obj_std_min = 7; // Minimum STD static const long obj_base_magic = 12; // Base amount of magic @@ -52,7 +32,6 @@ static void mt__ego_sword(treasure_type *treasure_ptr) { case 1: /*{Holy Avenger}*/ - strcat(treasure_ptr->name, " (HA)"); treasure_ptr->flags |= (See_Invisible_worn_bit | Sustain_Stat_worn_bit | Resist_Acid_worn_bit | Resist_Fire_worn_bit | Strength_worn_bit | Slay_Undead_worn_bit | @@ -68,7 +47,6 @@ static void mt__ego_sword(treasure_type *treasure_ptr) { case 2: /*{Defender}*/ - strcat(treasure_ptr->name, " [%P4] (DF)"); treasure_ptr->flags |= (Feather_Fall_worn_bit | See_Invisible_worn_bit | Resist_Lightning_worn_bit | Free_Action_worn_bit | @@ -85,7 +63,6 @@ static void mt__ego_sword(treasure_type *treasure_ptr) { case 3: /*{Demon Bane}*/ - strcat(treasure_ptr->name, " (DB)"); treasure_ptr->flags |= Resist_Fire_worn_bit; treasure_ptr->flags2 |= Slay_demon_worn_bit; treasure_ptr->tohit += 3; @@ -95,7 +72,6 @@ static void mt__ego_sword(treasure_type *treasure_ptr) { case 4: /* {Soul Sword}*/ - strcat(treasure_ptr->name, " (SS)"); treasure_ptr->flags |= (Intelligence_worn_bit | Wisdom_worn_bit | Charisma_worn_bit | See_Invisible_worn_bit | Regeneration_worn_bit); @@ -109,7 +85,6 @@ static void mt__ego_sword(treasure_type *treasure_ptr) { case 5: /*{Vorpal Sword}*/ - strcat(treasure_ptr->name, " (V)"); treasure_ptr->flags |= Sustain_Stat_worn_bit; treasure_ptr->flags2 |= Sharp_worn_bit; treasure_ptr->p1 = 1; @@ -123,7 +98,6 @@ static void mt__ego_sword(treasure_type *treasure_ptr) { static void mt__slaying_sword(treasure_type *treasure_ptr) { switch (randint(4)) { case 1: /* {Slay Monster}*/ - strcat(treasure_ptr->name, " (SM)"); treasure_ptr->flags |= (See_Invisible_worn_bit | Slay_Monster_worn_bit); treasure_ptr->tohit += 3; treasure_ptr->todam += 3; @@ -131,7 +105,6 @@ static void mt__slaying_sword(treasure_type *treasure_ptr) { break; case 2: /* {Slay Dragon}*/ - strcat(treasure_ptr->name, " (SD)"); treasure_ptr->flags |= Slay_Dragon_worn_bit; treasure_ptr->tohit += 3; treasure_ptr->todam += 3; @@ -139,7 +112,6 @@ static void mt__slaying_sword(treasure_type *treasure_ptr) { break; case 3: /* {Slay Undead}*/ - strcat(treasure_ptr->name, " (SU)"); treasure_ptr->flags |= Slay_Undead_worn_bit; treasure_ptr->tohit += 2; treasure_ptr->todam += 2; @@ -147,7 +119,6 @@ static void mt__slaying_sword(treasure_type *treasure_ptr) { break; case 4: /* {Slay Regenerative}*/ - strcat(treasure_ptr->name, " (SR)"); treasure_ptr->flags2 |= Slay_regen_worn_bit; treasure_ptr->tohit += 2; treasure_ptr->todam += 2; @@ -159,7 +130,6 @@ static void mt__slaying_sword(treasure_type *treasure_ptr) { static void mt__magic_sword(treasure_type *treasure_ptr) { switch (randint(4)) { case 1: /* {Flame Tongue}*/ - strcat(treasure_ptr->name, " (FT)"); treasure_ptr->flags |= Flame_Brand_worn_bit; treasure_ptr->tohit += 1; treasure_ptr->todam += 3; @@ -167,7 +137,6 @@ static void mt__magic_sword(treasure_type *treasure_ptr) { break; case 2: /* {Frost Brand}*/ - strcat(treasure_ptr->name, " (FB)"); treasure_ptr->flags |= Cold_Brand_worn_bit; treasure_ptr->tohit += 1; treasure_ptr->todam += 1; @@ -175,7 +144,6 @@ static void mt__magic_sword(treasure_type *treasure_ptr) { break; case 3: /* {Wizards Blade}*/ - strcat(treasure_ptr->name, " (WB)"); treasure_ptr->flags2 |= Magic_proof_worn_bit; treasure_ptr->weight = trunc(treasure_ptr->weight * 4 / 5); treasure_ptr->tval = dagger; /* let mages use it */ @@ -185,7 +153,6 @@ static void mt__magic_sword(treasure_type *treasure_ptr) { break; case 4: /* {Blessed Blade}*/ - strcat(treasure_ptr->name, " (BB)"); treasure_ptr->flags2 |= Magic_proof_worn_bit; treasure_ptr->tval = maul; /* let priests use it */ treasure_ptr->tohit += 2; @@ -259,8 +226,7 @@ static void mt__gems(treasure_type *treasure_ptr) { p1 = randint(6) + 4; break; default: - MSG(("WARNING: Unknown subval in mt__gems: %ld %s", treasure_ptr->subval, - treasure_ptr->name)); + MSG(("WARNING: Unknown subval in mt__gems: %ld", treasure_ptr->subval)); p1 = 0; break; } @@ -273,19 +239,16 @@ static void mt__misc_usable(treasure_type *treasure_ptr) { case 14: /* statues */ switch (randint(3)) { case 1: /* summoning undead */ - strcat(treasure_ptr->name, " Major of Undead Summoning"); treasure_ptr->flags |= 0x00000100; treasure_ptr->cost = 0; treasure_ptr->p1 = randint(4) + 2; break; case 2: /* summon demon */ - strcat(treasure_ptr->name, " Major of Demon Summoning"); treasure_ptr->flags |= 0x00000200; treasure_ptr->cost = 0; treasure_ptr->p1 = randint(3) + 1; break; case 3: /* Life giving */ - strcat(treasure_ptr->name, " Life Giving"); treasure_ptr->flags |= 0x00000400; treasure_ptr->cost = 900000; treasure_ptr->p1 = randint(5) + 3; @@ -296,13 +259,11 @@ static void mt__misc_usable(treasure_type *treasure_ptr) { case 15: /* teeth ? */ switch (randint(4)) { case 1: - strcat(treasure_ptr->name, " from a Dragon"); treasure_ptr->p1 = randint(4) + 2; treasure_ptr->cost += treasure_ptr->p1 * 20000; treasure_ptr->flags |= 0x20000000; break; case 2: - strcat(treasure_ptr->name, " of a Demon"); treasure_ptr->flags |= 0x40000000; treasure_ptr->p1 = randint(4) + 2; treasure_ptr->cost += treasure_ptr->p1 * 20000; @@ -320,13 +281,11 @@ static void mt__misc_usable(treasure_type *treasure_ptr) { case 1: case 2: case 3: - strcat(treasure_ptr->name, " of Turning"); treasure_ptr->flags |= 0x00000001; treasure_ptr->p1 = randint(treasure_ptr->p1 * 2) + 2; treasure_ptr->cost += treasure_ptr->p1 * 20000; break; case 4: - strcat(treasure_ptr->name, " of Demon Dispelling"); treasure_ptr->flags |= 0x00000002; treasure_ptr->p1 = randint(trunc(treasure_ptr->subval / 2)); treasure_ptr->cost += treasure_ptr->p1 * 50000; @@ -334,14 +293,13 @@ static void mt__misc_usable(treasure_type *treasure_ptr) { break; case 19: - strcat(treasure_ptr->name, " of Summon Undead"); treasure_ptr->flags |= 0x00000004; treasure_ptr->cost = 0; treasure_ptr->p1 = 2; break; case 20: - strcat(treasure_ptr->name, " of Demon Summoning"); + //strcat(treasure_ptr->name, " of Demon Summoning"); treasure_ptr->flags |= 0x00000008; treasure_ptr->cost = 0; treasure_ptr->p1 = 2; @@ -350,14 +308,12 @@ static void mt__misc_usable(treasure_type *treasure_ptr) { case 21: switch (randint(3)) { case 1: - strcat(treasure_ptr->name, " containing a Djinni"); treasure_ptr->flags |= 0x00000010; treasure_ptr->cost = 200000; treasure_ptr->p1 = 1; break; case 2: case 3: - strcat(treasure_ptr->name, " containing some Demons"); treasure_ptr->flags |= 0x00000020; treasure_ptr->cost = 0; treasure_ptr->p1 = 1; @@ -406,7 +362,6 @@ static void mt__armor_and_shields(treasure_type *treasure_ptr, long level, switch (randint(9)) { case 1: /*{ Resist }*/ - strcat(treasure_ptr->name, " (R)"); treasure_ptr->flags |= (Resist_Lightning_worn_bit | Resist_Cold_worn_bit | Resist_Acid_worn_bit | Resist_Fire_worn_bit); @@ -415,21 +370,18 @@ static void mt__armor_and_shields(treasure_type *treasure_ptr, long level, break; case 2: /*{ Resist Acid }*/ - strcat(treasure_ptr->name, " (RA)"); treasure_ptr->flags |= Resist_Acid_worn_bit; treasure_ptr->cost += 100000; break; case 3: /*{ Resist Fire }*/ case 4: - strcat(treasure_ptr->name, " (RF)"); treasure_ptr->flags |= Resist_Fire_worn_bit; treasure_ptr->cost += 60000; break; case 5: /*{ Resist Cold }*/ case 6: - strcat(treasure_ptr->name, " (RC)"); treasure_ptr->flags |= Resist_Cold_worn_bit; treasure_ptr->cost += 60000; break; @@ -437,7 +389,6 @@ static void mt__armor_and_shields(treasure_type *treasure_ptr, long level, case 7: /*{ Resist Lightning}*/ case 8: case 9: - strcat(treasure_ptr->name, " (RL)"); treasure_ptr->flags |= Resist_Lightning_worn_bit; treasure_ptr->cost += 50000; break; @@ -463,7 +414,6 @@ static void mt__weapons(treasure_type *treasure_ptr, long level, /* filthy rags? */ if (treasure_ptr->subval == 99 && randint(5) == 1) { - strcat(treasure_ptr->name, " of Trollkind"); treasure_ptr->flags |= (Charisma_worn_bit | Searching_worn_bit | Stealth_worn_bit | Regeneration_worn_bit | Resist_Acid_worn_bit | Resist_Cold_worn_bit); @@ -502,7 +452,6 @@ static void mt__bows_and_slings(treasure_type *treasure_ptr, long level, if (is_magic) { treasure_ptr->tohit = mt__m_bonus(1, 30, level, forceit); if (is_special) { - strcat(treasure_ptr->name, " of Criticals"); treasure_ptr->flags2 |= Sharp_worn_bit; treasure_ptr->tohit += 5; treasure_ptr->cost += 300000; @@ -540,26 +489,22 @@ static void mt__gloves_and_gauntlets(treasure_type *treasure_ptr, long level, if (is_special) { /* gloves_and_gauntlets 5 is "Set of Cloth Gloves" */ if (treasure_ptr->subval == 5 && randint(10) == 1) { - strcat(treasure_ptr->name, " of the Hive"); treasure_ptr->flags |= Dexterity_worn_bit; treasure_ptr->p1 = 2; treasure_ptr->cost += 50000; } else { switch (randint(5)) { case 1: - strcat(treasure_ptr->name, " of Free Action"); treasure_ptr->flags |= Free_Action_worn_bit; treasure_ptr->cost += 100000; break; case 2: - strcat(treasure_ptr->name, " of Slaying"); treasure_ptr->tohit = 1 + randint(3); treasure_ptr->todam = 1 + randint(3); treasure_ptr->cost += (treasure_ptr->tohit + treasure_ptr->todam) * 25000; break; case 3: - strcat(treasure_ptr->name, " of Thievery (%P1)"); treasure_ptr->flags2 |= Disarm_worn_bit; treasure_ptr->flags |= (Feather_Fall_worn_bit | See_Invisible_worn_bit); @@ -568,7 +513,6 @@ static void mt__gloves_and_gauntlets(treasure_type *treasure_ptr, long level, break; case 4: case 5: - strcat(treasure_ptr->name, " of Ogre Power"); treasure_ptr->flags |= (Slow_Digestion_worn_bit | Strength_worn_bit); treasure_ptr->p1 = randint(4); treasure_ptr->cost += 150000; @@ -580,17 +524,14 @@ static void mt__gloves_and_gauntlets(treasure_type *treasure_ptr, long level, if (is_special) { switch (randint(3)) { case 1: - strcat(treasure_ptr->name, " of Clumsiness"); treasure_ptr->flags |= (Cursed_worn_bit | Dexterity_worn_bit); treasure_ptr->p1 = 1; break; case 2: - strcat(treasure_ptr->name, " of Weakness"); treasure_ptr->flags |= (Cursed_worn_bit | Strength_worn_bit); treasure_ptr->p1 = 1; break; case 3: - strcat(treasure_ptr->name, " of Ogre Intelligence"); treasure_ptr->flags |= (Cursed_worn_bit | Intelligence_worn_bit); treasure_ptr->p1 = 1; break; @@ -610,7 +551,6 @@ static void mt__boots(treasure_type *treasure_ptr, long level, boolean is_magic, if (is_special) { switch (randint(16)) { case 1: - strcat(treasure_ptr->name, " of Speed"); treasure_ptr->flags |= Speed_worn_bit; treasure_ptr->p1 = 1; treasure_ptr->cost += 500000; @@ -619,14 +559,12 @@ static void mt__boots(treasure_type *treasure_ptr, long level, boolean is_magic, case 3: case 4: case 5: - strcat(treasure_ptr->name, " of Stealth"); treasure_ptr->flags |= Stealth_worn_bit; treasure_ptr->cost += 50000; break; default: if (treasure_ptr->subval == 4 && randint(6) == 1) { /* Pair of Sandals */ - strcat(treasure_ptr->name, " of Dryadkind"); treasure_ptr->flags |= (Charisma_worn_bit | Feather_Fall_worn_bit | See_Invisible_worn_bit | Free_Action_worn_bit); @@ -637,7 +575,6 @@ static void mt__boots(treasure_type *treasure_ptr, long level, boolean is_magic, } } } else { - strcat(treasure_ptr->name, " of Slow descent"); treasure_ptr->flags |= Feather_Fall_worn_bit; treasure_ptr->cost += 25000; } @@ -647,16 +584,13 @@ static void mt__boots(treasure_type *treasure_ptr, long level, boolean is_magic, switch (randint(3)) { case 1: - strcat(treasure_ptr->name, " of Slowness"); treasure_ptr->flags |= (Cursed_worn_bit | Speed_worn_bit); treasure_ptr->p1 = -1; break; case 2: - strcat(treasure_ptr->name, " of Noise"); treasure_ptr->flags |= (Cursed_worn_bit | Aggravation_worn_bit); break; case 3: - strcat(treasure_ptr->name, " of Great Mass"); treasure_ptr->flags |= Cursed_worn_bit; treasure_ptr->weight *= 5; break; @@ -675,19 +609,16 @@ static void mt__helms(treasure_type *treasure_ptr, long level, boolean is_magic, case 16: case 17: case 18: switch (randint(3)) { case 1: - strcat(treasure_ptr->name, " of Intelligence"); treasure_ptr->flags |= Intelligence_worn_bit; treasure_ptr->p1 = randint(2); treasure_ptr->cost += treasure_ptr->p1 * 50000; break; case 2: - strcat(treasure_ptr->name, " of Wisdom"); treasure_ptr->flags |= Wisdom_worn_bit; treasure_ptr->p1 = randint(2); treasure_ptr->cost += treasure_ptr->p1 * 50000; break; case 3: - strcat(treasure_ptr->name, " of Infra-Vision"); treasure_ptr->flags |= Infra_Vision_worn_bit; treasure_ptr->p1 = 1 + randint(4); treasure_ptr->cost += treasure_ptr->p1 * 25000; @@ -699,46 +630,39 @@ static void mt__helms(treasure_type *treasure_ptr, long level, boolean is_magic, case 19: case 20: case 21: case 22: case 23: switch (randint(6)) { case 1: - strcat(treasure_ptr->name, " of Might"); treasure_ptr->flags |= (Free_Action_worn_bit | Constitution_worn_bit | Strength_worn_bit | Dexterity_worn_bit); treasure_ptr->p1 = randint(3); treasure_ptr->cost += 100000 + treasure_ptr->p1 * 50000; break; case 2: - strcat(treasure_ptr->name, " of Lordliness"); treasure_ptr->flags |= (Wisdom_worn_bit | Charisma_worn_bit); treasure_ptr->p1 = randint(3); treasure_ptr->cost += 100000 + treasure_ptr->p1 * 50000; break; case 3: - strcat(treasure_ptr->name, " of the Magi"); treasure_ptr->flags |= (Free_Action_worn_bit | Strength_worn_bit | Constitution_worn_bit | Dexterity_worn_bit); treasure_ptr->p1 = randint(3); treasure_ptr->cost += 300000 + treasure_ptr->p1 * 50000; break; case 4: - strcat(treasure_ptr->name, " of Beauty"); treasure_ptr->flags |= Charisma_worn_bit; treasure_ptr->p1 = randint(3); treasure_ptr->cost += 75000; break; case 5: - strcat(treasure_ptr->name, " of Seeing"); treasure_ptr->flags |= (See_Invisible_worn_bit | Searching_worn_bit); treasure_ptr->p1 = 1 + randint(4); treasure_ptr->cost += 100000 + treasure_ptr->p1 * 10000; break; case 6: - strcat(treasure_ptr->name, " of Regeneration"); treasure_ptr->flags |= Regeneration_worn_bit; treasure_ptr->cost += 150000; break; } break; case 11: - strcat(treasure_ptr->name, " of Hobbitkind"); treasure_ptr->flags |= (Infra_Vision_worn_bit | See_Invisible_worn_bit | Free_Action_worn_bit | Searching_worn_bit); treasure_ptr->p1 = 5; @@ -753,45 +677,37 @@ static void mt__helms(treasure_type *treasure_ptr, long level, boolean is_magic, switch (randint(15)) { case 1: case 2: - strcat(treasure_ptr->name, " of Stupidity"); treasure_ptr->flags |= Intelligence_worn_bit; treasure_ptr->p1 = -1; break; case 3: case 4: - strcat(treasure_ptr->name, " of Dullness"); treasure_ptr->flags |= Wisdom_worn_bit; treasure_ptr->p1 = -1; break; case 5: case 6: - strcat(treasure_ptr->name, " of Blindness"); treasure_ptr->flags |= Blindness_worn_bit; break; case 7: case 8: - strcat(treasure_ptr->name, " of Timidness"); treasure_ptr->flags |= Timidness_worn_bit; break; case 9: case 10: - strcat(treasure_ptr->name, " of Weakness"); treasure_ptr->flags |= Strength_worn_bit; treasure_ptr->p1 = -1; break; case 11: case 12: - strcat(treasure_ptr->name, " of Teleportation"); treasure_ptr->flags |= Teleportation_worn_bit; break; case 13: case 14: - strcat(treasure_ptr->name, " of Ugliness"); treasure_ptr->flags |= Charisma_worn_bit; treasure_ptr->p1 = -1; break; case 15: - strcat(treasure_ptr->name, " of **TOTAL DOOM**"); treasure_ptr->flags |= (Cursed_worn_bit | Strength_worn_bit | Dexterity_worn_bit | Constitution_worn_bit | Intelligence_worn_bit | Wisdom_worn_bit | @@ -819,7 +735,6 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, switch (randint(16)) { case 1: if (randint(3) == 1) { - strcat(treasure_ptr->name, " of Titan Strength"); treasure_ptr->flags |= (Resist_Lightning_worn_bit | Resist_Fire_worn_bit | Resist_Cold_worn_bit | Resist_Acid_worn_bit | @@ -828,7 +743,6 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, treasure_ptr->p1 = 7; treasure_ptr->cost += 7500000; } else { - strcat(treasure_ptr->name, " of Storm Giant Strength"); treasure_ptr->flags |= (Resist_Lightning_worn_bit | Resist_Acid_worn_bit); treasure_ptr->flags2 |= (Magic_proof_worn_bit); @@ -837,7 +751,6 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, } break; case 2: - strcat(treasure_ptr->name, " of Cloud Giant Strength"); treasure_ptr->flags |= (Resist_Lightning_worn_bit | Resist_Acid_worn_bit); treasure_ptr->p1 = 5; @@ -845,7 +758,6 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, break; case 3: case 4: - strcat(treasure_ptr->name, " of Fire Giant Strength"); treasure_ptr->flags |= Resist_Fire_worn_bit; treasure_ptr->p1 = 4; treasure_ptr->cost += 1750000; @@ -853,7 +765,6 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, case 5: case 6: case 7: - strcat(treasure_ptr->name, " of Frost Giant Strength"); treasure_ptr->flags |= Resist_Cold_worn_bit; treasure_ptr->p1 = 3; treasure_ptr->cost += 1250000; @@ -862,7 +773,6 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, case 9: case 10: case 11: - strcat(treasure_ptr->name, " of Stone Giant Strength"); treasure_ptr->p1 = 2; treasure_ptr->cost += 800000; break; @@ -871,7 +781,6 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, case 14: case 15: case 16: - strcat(treasure_ptr->name, " of Hill Giant Strength"); treasure_ptr->p1 = 1; treasure_ptr->cost += 600000; break; @@ -884,13 +793,11 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, case 11: switch (randint(2)) { case 1: - strcat(treasure_ptr->name, " of Deflection"); treasure_ptr->flags2 |= Magic_proof_worn_bit; treasure_ptr->toac += randint(5); treasure_ptr->cost += treasure_ptr->toac * 20000; break; case 2: - strcat(treasure_ptr->name, " of Improved Digestion"); treasure_ptr->flags |= (Sustain_Stat_worn_bit | Slow_Digestion_worn_bit); treasure_ptr->p1 = 2; @@ -900,7 +807,6 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, break; case 13: /* Leather Belt */ - strcat(treasure_ptr->name, " of Dwarvenkind"); treasure_ptr->flags |= (Infra_Vision_worn_bit | Tunneling_worn_bit | Sustain_Stat_worn_bit); treasure_ptr->flags2 |= Magic_proof_worn_bit; @@ -918,12 +824,10 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, case 1: /* Girdle */ switch (randint(2)) { case 1: - strcat(treasure_ptr->name, " of Sex Change"); treasure_ptr->flags |= Charisma_worn_bit; treasure_ptr->p1 = -2; break; case 2: - strcat(treasure_ptr->name, " of Weakness"); treasure_ptr->flags |= Strength_worn_bit; treasure_ptr->p1 = -1; break; @@ -932,12 +836,10 @@ static void mt__belt(treasure_type *treasure_ptr, long level, boolean is_magic, case 10: /* Silver Belt Buckle, Gold Belt Buckle */ case 11: - strcat(treasure_ptr->name, " of Fear"); treasure_ptr->flags |= (Cursed_worn_bit | Timidness_worn_bit); treasure_ptr->p1 = -1; break; case 13: /* Leather Belt */ - strcat(treasure_ptr->name, " of Hunger"); treasure_ptr->flags |= Cursed_worn_bit; treasure_ptr->flags2 |= Hunger_worn_bit; treasure_ptr->p1 = -1; @@ -1168,8 +1070,7 @@ static void mt__wand(treasure_type *treasure_ptr, boolean forceit) { p1 = randint(20) + 10; break; default: - MSG(("WARNING: Unknown subval in mt__wand: %ld %s", treasure_ptr->subval, - treasure_ptr->name)); + MSG(("WARNING: Unknown subval in mt__wand: %ld", treasure_ptr->subval)); p1 = 0; break; } @@ -1263,8 +1164,7 @@ static void mt__staff(treasure_type *treasure_ptr, boolean forceit) { p1 = randint(6) + 6; break; default: - MSG(("WARNING: Unknown subval in mt__staff: %ld %s", treasure_ptr->subval, - treasure_ptr->name)); + MSG(("WARNING: Unknown subval in mt__staff: %ld", treasure_ptr->subval)); p1 = 0; break; } @@ -1328,8 +1228,7 @@ static void mt__chime(treasure_type *treasure_ptr, boolean forceit) { p1 = randint(10) + 6; break; default: - MSG(("WARNING: Unknown subval in mt__chime: %ld %s", treasure_ptr->subval, - treasure_ptr->name)); + MSG(("WARNING: Unknown subval in mt__chime: %ld", treasure_ptr->subval)); p1 = 0; break; } @@ -1384,8 +1283,7 @@ static void mt__horn(treasure_type *treasure_ptr, boolean forceit) { p1 = randint(8) + 1; break; default: - MSG(("WARNING: Unknown subval in mt__horn: %ld %s", treasure_ptr->subval, - treasure_ptr->name)); + MSG(("WARNING: Unknown subval in mt__horn: %ld", treasure_ptr->subval)); p1 = 0; break; } @@ -1405,7 +1303,6 @@ static void mt__cloak(treasure_type *treasure_ptr, long level, boolean is_magic, case 2: case 3: case 4: - strcat(treasure_ptr->name, " of Protection"); treasure_ptr->toac = mt__m_bonus(2, 40, level, forceit); treasure_ptr->cost += 25000 + treasure_ptr->toac * 10000; break; @@ -1413,7 +1310,6 @@ static void mt__cloak(treasure_type *treasure_ptr, long level, boolean is_magic, case 6: case 7: case 8: - strcat(treasure_ptr->name, " of Stealth (%P1)"); treasure_ptr->flags |= Stealth_worn_bit; treasure_ptr->toac = mt__m_bonus(1, 20, level, forceit); treasure_ptr->p1 = randint(3); @@ -1421,7 +1317,6 @@ static void mt__cloak(treasure_type *treasure_ptr, long level, boolean is_magic, treasure_ptr->p1 * 50000 + treasure_ptr->toac * 10000; break; case 9: - strcat(treasure_ptr->name, " of Elvenkind"); treasure_ptr->flags |= (See_Invisible_worn_bit | Sustain_Stat_worn_bit | Stealth_worn_bit | Charisma_worn_bit); treasure_ptr->p1 = 2; @@ -1436,7 +1331,6 @@ static void mt__cloak(treasure_type *treasure_ptr, long level, boolean is_magic, } else if (is_cursed) { switch (randint(3)) { case 1: - strcat(treasure_ptr->name, " of Irritation"); treasure_ptr->flags |= (Cursed_worn_bit | Aggravation_worn_bit); treasure_ptr->ac = 0; treasure_ptr->toac = -mt__m_bonus(1, 10, level, forceit); @@ -1445,14 +1339,12 @@ static void mt__cloak(treasure_type *treasure_ptr, long level, boolean is_magic, treasure_ptr->cost = 0; break; case 2: - strcat(treasure_ptr->name, " of Vulnerability"); treasure_ptr->flags |= Cursed_worn_bit; treasure_ptr->ac = 0; treasure_ptr->toac = -mt__m_bonus(10, 100, level + 50, forceit); treasure_ptr->cost = 0; break; case 3: - strcat(treasure_ptr->name, " of Enveloping"); treasure_ptr->flags |= Cursed_worn_bit; treasure_ptr->toac = -mt__m_bonus(1, 10, level, forceit); treasure_ptr->tohit = -mt__m_bonus(2, 40, level + 10, forceit); @@ -1476,51 +1368,41 @@ static void mt__chest(treasure_type *treasure_ptr, long level) { if (treasure_ptr->subval == 5) { /* dead human body */ - strcat(treasure_ptr->name, "^ (Looted)"); } else { switch (randint(level) + 4) { case 1: - strcat(treasure_ptr->name, "^ (Empty)"); break; case 2: - strcat(treasure_ptr->name, "^ (Locked)"); treasure_ptr->flags |= 0x00000001; break; case 3: case 4: - strcat(treasure_ptr->name, "^ (Poison Needle)"); treasure_ptr->flags |= 0x00000011; break; case 5: case 6: - strcat(treasure_ptr->name, "^ (Poison Needle)"); treasure_ptr->flags |= 0x00000021; break; case 7: case 8: case 9: - strcat(treasure_ptr->name, "^ (Gas Trap)"); treasure_ptr->flags |= 0x00000041; break; case 10: case 11: - strcat(treasure_ptr->name, "^ (Explosion Device)"); treasure_ptr->flags |= 0x00000081; break; case 12: case 13: case 14: - strcat(treasure_ptr->name, "^ (Summoning Runes)"); treasure_ptr->flags |= 0x00000101; break; case 15: case 16: case 17: - strcat(treasure_ptr->name, "^ (Multiple Traps)"); treasure_ptr->flags |= 0x00000071; break; default: - strcat(treasure_ptr->name, "^ (Multiple Traps)"); treasure_ptr->flags |= 0x00000181; break; } @@ -1552,14 +1434,12 @@ static void mt__ammo(treasure_type *treasure_ptr, long level, boolean is_magic, case 1: case 2: case 3: - strcat(treasure_ptr->name, " of Slaying"); treasure_ptr->tohit += 5; treasure_ptr->todam += 5; treasure_ptr->cost += 2000; break; case 4: case 5: - strcat(treasure_ptr->name, " of Fire"); treasure_ptr->flags |= Flame_Brand_worn_bit; treasure_ptr->tohit += 2; treasure_ptr->todam += 4; @@ -1567,7 +1447,6 @@ static void mt__ammo(treasure_type *treasure_ptr, long level, boolean is_magic, break; case 6: case 7: - strcat(treasure_ptr->name, " of Slay Evil"); treasure_ptr->flags |= Slay_Evil_worn_bit; treasure_ptr->tohit += 3; treasure_ptr->todam += 3; @@ -1575,14 +1454,12 @@ static void mt__ammo(treasure_type *treasure_ptr, long level, boolean is_magic, break; case 8: case 9: - strcat(treasure_ptr->name, " of Slay Monster"); treasure_ptr->flags |= Slay_Monster_worn_bit; treasure_ptr->tohit += 2; treasure_ptr->todam += 2; treasure_ptr->cost += 3000; break; case 10: - strcat(treasure_ptr->name, " of Dragon Slaying"); treasure_ptr->flags |= Slay_Dragon_worn_bit; treasure_ptr->tohit += 10; treasure_ptr->todam += 10; @@ -1689,7 +1566,9 @@ void magic_treasure(long x, long level, boolean forceit) { mt__weapons(treasure_ptr, level, is_magic, is_special, is_cursed, forceit); break; - case bow_crossbow_or_sling: + case bow: + case crossbow: + case sling: mt__bows_and_slings(treasure_ptr, level, is_magic, is_special, is_cursed, forceit); break; diff --git a/src/treasures.h b/src/treasures.h index 8404faad..d9990bdb 100644 --- a/src/treasures.h +++ b/src/treasures.h @@ -2,12 +2,10 @@ #define TREASURES_H #include "constants.h" - -// Descriptive constants -#define MAX_SYLLABLES 156 // Used with scrolls - -extern char const *syllables[MAX_SYLLABLES]; +#include "types.h" extern long t_level[MAX_OBJ_LEVEL + 1]; +extern void magic_treasure(long x, long level, boolean forceit); + #endif // TREASURES_H diff --git a/src/types.h b/src/types.h index 9125553f..2af56aed 100644 --- a/src/types.h +++ b/src/types.h @@ -90,6 +90,69 @@ enum store_t { S_GENERIC_5 = 22, /* 'the entrance to a building' */ }; +enum item_t { + miscellaneous_object = 1, + chest = 2, + misc_usable = 3, + valuable_jewelry = 4, + valuable_gems = 5, + bag_or_sack = 6, + valuable_gems_wear = 7, + sling_ammo = 10, + bolt = 11, + arrow = 12, + spike = 13, + lamp_or_torch = 15, + bow = 16, + crossbow = 17, + sling = 18, + hafted_weapon = 21, + pole_arm = 22, + dagger = 23, + sword = 24, + pick_or_shovel = 25, + maul = 26, + gem_helm = 29, + boots = 30, + gloves_and_gauntlets = 31, + cloak = 32, + helm = 33, + shield = 34, + hard_armor = 35, + soft_armor = 36, + bracers = 37, + belt = 38, + amulet = 40, + ring = 45, + staff = 55, + wand = 65, + Scroll = 70, + potion = 75, + flask_of_oil = 77, + Food = 80, + junk_food = 81, + chime = 85, + horn = 86, + magic_book = 90, + prayer_book = 91, + instrument = 92 /* Not in use */, + song_book = 93, + lodging_at_inn = 95, + valuable_metal = 100 /* look in detect_item for limit */, + unseen_trap = 101, + seen_trap = 102, + rubble = 103, + open_door = 104, + closed_door = 105, + up_staircase = 107, + down_staircase = 108, + secret_door = 109, + entrance_to_store = 110, + up_steep_staircase = 111, + down_steep_staircase = 112, + whirlpool = 113, +}; + typedef struct game_time_type { int64_t year; uint8_t month; @@ -144,7 +207,6 @@ typedef struct monster_type { } monster_type; typedef struct treasure_type { - char name[70]; /* Object name */ uint8_t tval; /* Catagory number */ uint64_t flags2; /*: unsigned; { MORE Special flags } */ uint64_t flags; /*: unsigned; { Special flags } */ diff --git a/src/variables.c b/src/variables.c index 62cd4ac0..fb3f753b 100644 --- a/src/variables.c +++ b/src/variables.c @@ -124,15 +124,13 @@ obj_set water_set = {16, 17, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; obj_set earth_set = {1, 2, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; obj_set float_set = {arrow, lamp_or_torch, - bow_crossbow_or_sling, + bow, crossbow, sling, boots, gloves_and_gauntlets, cloak, soft_armor, - scroll1, - scroll2, - potion1, - potion2, + Scroll, + potion, flask_of_oil, Food, magic_book, @@ -177,43 +175,43 @@ long com_val; /* generated. (also mt__food in the same file) */ treasure_type yums[NUM_YUM + 1] = { - {"& Bogus Hard Biscuit~", Food, 0x00000000, Nothing_flag, 500, 1, 309, 2, 1, + {Food, 0x00000000, Nothing_flag, 500, 1, 309, 2, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Hard Biscuit~", Food, 0x00000000, Nothing_flag, 500, 1, 309, 2, 1, 0, 0, + {Food, 0x00000000, Nothing_flag, 500, 1, 309, 2, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Pint of Fine Wine", Food, 0x00000000, Nothing_flag, 400, 2, 312, 10, 1, + {Food, 0x00000000, Nothing_flag, 400, 2, 312, 10, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Strip~ of Beef Jerky", Food, 0x00000000, Nothing_flag, 1750, 2, 310, 2, + {Food, 0x00000000, Nothing_flag, 1750, 2, 310, 2, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Piece~ of Elvish Waybread", Food, 0x00000000, 0x21800020, 3500, 10, 313, + {Food, 0x00000000, 0x21800020, 3500, 10, 313, 3, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Stew~", Food, 0x00000000, 0x330001C0, 2000, 0, 314, 3, 1, 0, 0, 0, 0, + {Food, 0x00000000, 0x330001C0, 2000, 0, 314, 3, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Green Jelly~", Food, 0x00000000, 0x22400060, 4000, 50, 315, 3, 1, 0, 0, + {Food, 0x00000000, 0x22400060, 4000, 50, 315, 3, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& pint~ of fine grade mush", Food, 0x00000000, 0x00000000, 1500, 0, 306, + {Food, 0x00000000, 0x00000000, 1500, 0, 306, 252, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Mushroom~", Food, 0x00000000, Nothing_flag, 3000, 2, 308, 5, 1, 0, 0, 0, + {Food, 0x00000000, Nothing_flag, 3000, 2, 308, 5, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Pint of Fine Ale", Food, 0x00000000, Nothing_flag, 500, 1, 311, 10, 1, + { Food, 0x00000000, Nothing_flag, 500, 1, 311, 10, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Handful~ of Berries| (Smurfberries)", Food, 0x00000000, 0x30400000, + {Food, 0x00000000, 0x30400000, 1000, 0, 317, 3, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Handful~ of Berries| (Goodberries)", Food, 0x00000000, 0x30C00080, 1000, + {Food, 0x00000000, 0x30C00080, 1000, 0, 318, 3, 1, 0, 0, 0, 0, "0d0", -1, 0}, - {"& Cool Set of Threads^ [%P6,%P4]", soft_armor, 0x00000000, Nothing_flag, + {soft_armor, 0x00000000, Nothing_flag, 0, 45, 11, 75, 1, -1, 0, 3, 0, "0d0", -1, 0}, - {"Filthy Naga Hide Armor^ [%P6,%P4]", soft_armor, 0x00000000, Nothing_flag, + {soft_armor, 0x00000000, Nothing_flag, 0, 45, 12, 300, 1, -1, 0, 9, 0, "0d0", -1, 0}, - {"Stone Plate Armor^ [%P6,%P4]", hard_armor, 0x00000000, Nothing_flag, 0, + {hard_armor, 0x00000000, Nothing_flag, 0, 45, 14, 600, 1, -6, 0, 10, 0, "2d4", -1, 0}, - {"Elven Chain Mail^ [%P6,%P4]", soft_armor, 0x00000000, Nothing_flag, 0, + {soft_armor, 0x00000000, Nothing_flag, 0, 900, 13, 160, 1, -1, 0, 17, 0, "1d2", -1, 0}, - {"Mithril Chain Mail^ [%P6,%P4]", hard_armor, 0x00000000, Nothing_flag, 0, + {hard_armor, 0x00000000, Nothing_flag, 0, 1800, 15, 240, 1, -1, 0, 24, 0, "1d4", -1, 0}, - {"Mithril Plate Armor^ [%P6,%P4]", hard_armor, 0x00000000, Nothing_flag, 0, + {hard_armor, 0x00000000, Nothing_flag, 0, 3600, 16, 400, 1, -1, 0, 32, 0, "2d4", -1, 0}, - {"& Eyeball~| of Drong", junk_food, 0x00000000, 0x00000000, 300, 1000, 270, + {junk_food, 0x00000000, 0x00000000, 300, 1000, 270, 2, 2, 0, 0, 0, 0, "10d12", 20, 0}, /*{18} */ }; @@ -224,112 +222,86 @@ store_type stores[MAX_STORES + 1]; /* { Stores are just special traps } */ treasure_type store_door[MAX_STORES + MAX_UNNAMED + 5 + 1] = { - {"the entrance to the General Store", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 101, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Armory", entrance_to_store, 0x00000000, 0x00000000, 0, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 102, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Weapon Smiths", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 103, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Temple", entrance_to_store, 0x00000000, 0x00000000, 0, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 104, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Alchemy Shop", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 105, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Magic Shop", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 106, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Inn", entrance_to_store, 0x00000000, 0x00000000, 0, 0, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 107, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Library", entrance_to_store, 0x00000000, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 109, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Music Shop", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 110, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Gem Store", entrance_to_store, 0x00000000, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 113, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the All-Nite Deli", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 116, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, /* this is the black market, it looks like a normal door */ - {"the entrance to a building", entrance_to_store, 0x00000000, 0x00000000, 0, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 118, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Trading Post", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 108, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Insurance Shop", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 111, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Bank", entrance_to_store, 0x00000000, 0x00000000, 0, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 112, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Money Exchange", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 114, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to the Casino", entrance_to_store, 0x00000000, 0x00000000, 0, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 115, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to a strange building", entrance_to_store, 0x00000000, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 117, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to a building", entrance_to_store, 0x00000000, 0x00000000, 0, + { entrance_to_store, 0x00000000, 0x00000000, 0, 0, 120, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to a building", entrance_to_store, 0x00000000, 0x00000000, 0, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 121, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to a building", entrance_to_store, 0x00000000, 0x00000000, 0, + { entrance_to_store, 0x00000000, 0x00000000, 0, 0, 122, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to a building", entrance_to_store, 0x00000000, 0x00000000, 0, + { entrance_to_store, 0x00000000, 0x00000000, 0, 0, 123, 0, 0, 0, 0, 0, 0, "0d0", 0, 0}, - {"the entrance to a building", entrance_to_store, 0x00000000, 0x00000000, 0, + {entrance_to_store, 0x00000000, 0x00000000, 0, 0, 124, 0, 0, 0, 0, 0, 0, "0d0", 0, 0} }; long mugging_chance; /* { Chance page gets mugged} */ -boolean object_ident[MAX_OBJECTS + 1]; /*(max_objects of false) */ - /* { Gold list (All types of gold and gems are defined here) } */ -treasure_type gold_list[MAX_GOLD] = {{"& copper piece~", valuable_metal, 0, 0, - 0, 0, 2, 5, 420, 0, 0, 0, 0, " ", 2, 0}, - {"& iron piece~", valuable_metal, 0, 0, 0, - 0, 1, 5, 2400, 0, 0, 0, 0, " ", 1, 0}, - {"& copper piece~", valuable_metal, 0, 0, - 0, 0, 4, 5, 720, 0, 0, 0, 0, " ", 2, 0}, - {"& silver piece~", valuable_metal, 0, 0, - 0, 0, 5, 5, 180, 0, 0, 0, 0, " ", 3, 0}, - {"& iron piece~", valuable_metal, 0, 0, 0, - 0, 3, 5, 4800, 0, 0, 0, 0, " ", 1, 0}, - {"& copper piece~", valuable_metal, 0, 0, - 0, 0, 6, 5, 1200, 0, 0, 0, 0, " ", 2, 0}, - {"& silver piece~", valuable_metal, 0, 0, - 0, 0, 7, 5, 300, 0, 0, 0, 0, " ", 3, 0}, - {"& gold piece~", valuable_metal, 0, 0, 0, - 0, 12, 5, 30, 0, 0, 0, 0, " ", 4, 0}, - {"& iron piece~", valuable_metal, 0, 0, 0, - 0, 3, 5, 9000, 0, 0, 0, 0, " ", 1, 0}, - {"& copper piece~", valuable_metal, 0, 0, - 0, 0, 6, 5, 2400, 0, 0, 0, 0, " ", 2, 0}, - {"& silver piece~", valuable_metal, 0, 0, - 0, 0, 7, 5, 600, 0, 0, 0, 0, " ", 3, 0}, - {"& gold piece~", valuable_metal, 0, 0, 0, - 0, 12, 5, 60, 0, 0, 0, 0, " ", 4, 0}, - {"& copper piece~", valuable_metal, 0, 0, - 0, 0, 6, 5, 6000, 0, 0, 0, 0, " ", 2, 0}, - {"& silver piece~", valuable_metal, 0, 0, - 0, 0, 7, 5, 1200, 0, 0, 0, 0, " ", 3, 0}, - {"& gold piece~", valuable_metal, 0, 0, 0, - 0, 12, 5, 120, 0, 0, 0, 0, " ", 4, 0}, - {"& silver piece~", valuable_metal, 0, 0, - 0, 0, 7, 5, 1500, 0, 0, 0, 0, " ", 3, 0}, - {"& gold piece~", valuable_metal, 0, 0, 0, - 0, 18, 5, 150, 0, 0, 0, 0, " ", 4, 0}, - {"& platinum piece~", valuable_metal, 0, 0, - 0, 0, 20, 5, 50, 0, 0, 0, 0, " ", 5, 0}, - {"& silver piece~", valuable_metal, 0, 0, - 0, 0, 16, 5, 3000, 0, 0, 0, 0, " ", 3, 0}, - {"& gold piece~", valuable_metal, 0, 0, 0, - 0, 24, 5, 250, 0, 0, 0, 0, " ", 4, 0}, - {"& platinum piece~", valuable_metal, 0, 0, - 0, 0, 28, 5, 75, 0, 0, 0, 0, " ", 5, 0}, - {"& mithril piece~", valuable_metal, 0, 0, - 0, 0, 32, 5, 8, 0, 0, 0, 0, " ", 6, 0}, - {"& gold piece~", valuable_metal, 0, 0, 0, - 0, 50, 5, 600, 0, 0, 0, 0, " ", 4, 0}, - {"& platinum piece~", valuable_metal, 0, 0, - 0, 0, 55, 5, 200, 0, 0, 0, 0, " ", 5, 0}, - {"& mithril piece~", valuable_metal, 0, 0, - 0, 0, 60, 5, 20, 0, 0, 0, 0, " ", 6, 0} +treasure_type gold_list[MAX_GOLD] = { + {valuable_metal, 0, 0, 0, 0, 2, 5, 420, 0, 0, 0, 0, " ", 2, 0}, + {valuable_metal, 0, 0, 0, 0, 1, 5, 2400, 0, 0, 0, 0, " ", 1, 0}, + {valuable_metal, 0, 0, 0, 0, 4, 5, 720, 0, 0, 0, 0, " ", 2, 0}, + {valuable_metal, 0, 0, 0, 0, 5, 5, 180, 0, 0, 0, 0, " ", 3, 0}, + {valuable_metal, 0, 0, 0, 0, 3, 5, 4800, 0, 0, 0, 0, " ", 1, 0}, + {valuable_metal, 0, 0, 0, 0, 6, 5, 1200, 0, 0, 0, 0, " ", 2, 0}, + {valuable_metal, 0, 0, 0, 0, 7, 5, 300, 0, 0, 0, 0, " ", 3, 0}, + {valuable_metal, 0, 0, 0, 0, 12, 5, 30, 0, 0, 0, 0, " ", 4, 0}, + {valuable_metal, 0, 0, 0, 0, 3, 5, 9000, 0, 0, 0, 0, " ", 1, 0}, + {valuable_metal, 0, 0, 0, 0, 6, 5, 2400, 0, 0, 0, 0, " ", 2, 0}, + {valuable_metal, 0, 0, 0, 0, 7, 5, 600, 0, 0, 0, 0, " ", 3, 0}, + {valuable_metal, 0, 0, 0, 0, 12, 5, 60, 0, 0, 0, 0, " ", 4, 0}, + {valuable_metal, 0, 0, 0, 0, 6, 5, 6000, 0, 0, 0, 0, " ", 2, 0}, + {valuable_metal, 0, 0, 0, 0, 7, 5, 1200, 0, 0, 0, 0, " ", 3, 0}, + {valuable_metal, 0, 0, 0, 0, 12, 5, 120, 0, 0, 0, 0, " ", 4, 0}, + {valuable_metal, 0, 0, 0, 0, 7, 5, 1500, 0, 0, 0, 0, " ", 3, 0}, + {valuable_metal, 0, 0, 0, 0, 18, 5, 150, 0, 0, 0, 0, " ", 4, 0}, + {valuable_metal, 0, 0, 0, 0, 20, 5, 50, 0, 0, 0, 0, " ", 5, 0}, + {valuable_metal, 0, 0, 0, 0, 16, 5, 3000, 0, 0, 0, 0, " ", 3, 0}, + {valuable_metal, 0, 0, 0, 0, 24, 5, 250, 0, 0, 0, 0, " ", 4, 0}, + {valuable_metal, 0, 0, 0, 0, 28, 5, 75, 0, 0, 0, 0, " ", 5, 0}, + {valuable_metal, 0, 0, 0, 0, 32, 5, 8, 0, 0, 0, 0, " ", 6, 0}, + {valuable_metal, 0, 0, 0, 0, 50, 5, 600, 0, 0, 0, 0, " ", 4, 0}, + {valuable_metal, 0, 0, 0, 0, 55, 5, 200, 0, 0, 0, 0, " ", 5, 0}, + {valuable_metal, 0, 0, 0, 0, 60, 5, 20, 0, 0, 0, 0, " ", 6, 0} }; @@ -337,7 +309,7 @@ treasure_type t_list[MAX_TALLOC + 1]; treasure_type equipment[EQUIP_MAX]; treas_rec *inventory_list = NULL; treas_rec inven_temp = { - .data = {" ", 0, 0, 0, 0, 0, 0, 0, + .data = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, " ", 0, 0}, .ok = false, .insides = 0, @@ -345,7 +317,7 @@ treas_rec inven_temp = { .is_in = false, }; -treasure_type blank_treasure = {" ", 0, 0, 0, 0, 0, 0, 0, +treasure_type blank_treasure = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, " ", 0, 0}; long inven_ctr = 0; /* { Total different obj's} */ long inven_weight = 0; /* { Cur carried weight } */ @@ -356,13 +328,10 @@ long equip_ctr = 0; /* { Cur equipment ctr } */ /* { Secret door must have same subval as closed door in } */ /* { TRAP_LISTB. See CHANGE_TRAP } */ -treasure_type door_list[3] = { - {"an open door", open_door, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, - 0, "1d1", 0, 0}, - {"a closed door", closed_door, 0x00000000, 0x00000000, 0, 0, 19, 0, 0, 0, 0, - 0, 0, "1d1", 0, 0}, - {"a secret door", secret_door, 0x00000000, 0x00000000, 0, 0, 19, 0, 0, 0, 0, - 0, 0, "1d1", 0, 0}}; +treasure_type door_open = {open_door, 0x00000000, 0x00000000, 0, 0, 1, 0, 0, 0, 0, 0, + 0, "1d1", 0, 0}; +treasure_type door_closed = {closed_door, 0x00000000, 0x00000000, 0, 0, 19, 0, 0, 0, 0, 0, 0, "1d1", 0, 0}; +treasure_type door_secret = {secret_door, 0x00000000, 0x00000000, 0, 0, 19, 0, 0, 0, 0, 0, 0, "1d1", 0, 0}; /* { Following are creature arrays and variables } */ creature_type c_list[MAX_CREATURES + 1]; diff --git a/src/variables.h b/src/variables.h index 6fdfca49..714eabda 100644 --- a/src/variables.h +++ b/src/variables.h @@ -93,7 +93,6 @@ extern treasure_type store_door[MAX_STORES + MAX_UNNAMED + 5 + 1]; extern long mugging_chance; /* { Chance page gets mugged} */ /* { Following are treasure arrays and variables } */ -extern boolean object_ident[MAX_OBJECTS + 1]; extern treasure_type gold_list[MAX_GOLD]; extern treasure_type t_list[MAX_TALLOC + 1]; extern treasure_type equipment[EQUIP_MAX]; @@ -105,7 +104,9 @@ extern long inven_weight; /* { Cur carried weight } */ extern long equip_ctr; /* { Cur equipment ctr } */ /* { Following are feature objects defined for dungeon } */ -extern treasure_type door_list[3]; +extern treasure_type door_open; +extern treasure_type door_closed; +extern treasure_type door_secret; /* { Following are creature arrays and variables } */ extern creature_type c_list[MAX_CREATURES + 1]; diff --git a/src/wands.c b/src/wands.c index fe546e0e..3f46b75f 100644 --- a/src/wands.c +++ b/src/wands.c @@ -218,7 +218,7 @@ void aim_wand() { aw__wand_effects(i5, &ident, dir, i3, i4); } if (ident) { - identify(&(item_ptr->data)); + set_type_identified(item_ptr->data.tval, item_ptr->data.subval, true); } if (item_ptr->data.flags != 0) { /* with player_do; */ diff --git a/src/wizard.c b/src/wizard.c index 33f2e961..2f58635c 100644 --- a/src/wizard.c +++ b/src/wizard.c @@ -338,7 +338,6 @@ void si__pesky_stuff(long *best_value, long *good_value, popt(cur_pos); cave[y][x].tptr = *cur_pos; t_list[*cur_pos] = blank_treasure; - sprintf(t_list[*cur_pos].name, "& bogus summoned item %ld", *cur_pos); } boolean si__optimize_item(treasure_type *pick, long *value, long optimize, @@ -722,13 +721,6 @@ void wizard_create() { msg_flag = false; /* with inven_temp->data do; */ - prt("Name : ", 1, 1); - if (get_string(tmp_str, 1, 10, 40)) { - strcpy(inven_temp.data.name, tmp_str); - } else { - strcpy(inven_temp.data.name, "& Wizard Object!"); - } - do { prt("Tval : ", 1, 1); get_string(tmp_str, 1, 10, 10); @@ -919,10 +911,9 @@ void wizard_command(void) { break; case 'i': msg_print("Poof! Your items are all identifed!!!"); - for (trash_ptr = inventory_list; trash_ptr != NULL;) { - identify(&(trash_ptr->data)); - known2(trash_ptr->data.name); - trash_ptr = trash_ptr->next; + for (trash_ptr = inventory_list; trash_ptr != NULL; trash_ptr = trash_ptr->next) { + trash_ptr->data.identified = true; + set_type_identified(trash_ptr->data.tval, trash_ptr->data.subval, true); } break; case 'j': /* Gain exp */