···11+# condition_overload
22+33+[](https://hex.pm/packages/condition_overload)
44+[](https://hexdocs.pm/condition_overload/)
55+66+```sh
77+gleam add condition_overload@1
88+```
99+```gleam
1010+import condition_overload
1111+1212+pub fn main() -> Nil {
1313+ // TODO: An example of the project in use
1414+}
1515+```
1616+1717+Further documentation can be found at <https://hexdocs.pm/condition_overload>.
1818+1919+## Development
2020+2121+```sh
2222+gleam run # Run the project
2323+gleam test # Run the tests
2424+```
+25
gleam.toml
···11+name = "condition_overload"
22+version = "1.0.0"
33+44+# Fill out these fields if you intend to generate HTML documentation or publish
55+# your project to the Hex package manager.
66+#
77+# description = ""
88+# licences = ["Apache-2.0"]
99+# repository = { type = "github", user = "", repo = "" }
1010+# links = [{ title = "Website", href = "" }]
1111+#
1212+# For a full reference of all the available options, you can have a look at
1313+# https://gleam.run/writing-gleam/gleam-toml/.
1414+1515+[dependencies]
1616+gleam_stdlib = ">= 0.44.0 and < 2.0.0"
1717+gleam_http = ">= 4.1.1 and < 5.0.0"
1818+gleam_httpc = ">= 5.0.0 and < 6.0.0"
1919+gleam_hackney = ">= 1.3.1 and < 2.0.0"
2020+shellout = ">= 1.7.0 and < 2.0.0"
2121+html_parser = ">= 1.0.1 and < 2.0.0"
2222+splitter = ">= 1.0.0 and < 2.0.0"
2323+2424+[dev-dependencies]
2525+gleeunit = ">= 1.0.0 and < 2.0.0"
+32
manifest.toml
···11+# This file was generated by Gleam
22+# You typically do not need to edit this file
33+44+packages = [
55+ { name = "certifi", version = "2.15.0", build_tools = ["rebar3"], requirements = [], otp_app = "certifi", source = "hex", outer_checksum = "B147ED22CE71D72EAFDAD94F055165C1C182F61A2FF49DF28BCC71D1D5B94A60" },
66+ { name = "gleam_erlang", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "F91CE62A2D011FA13341F3723DB7DB118541AAA5FE7311BD2716D018F01EF9E3" },
77+ { name = "gleam_hackney", version = "1.3.1", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib", "hackney"], otp_app = "gleam_hackney", source = "hex", outer_checksum = "0449AADBEBF3E979509A4079EE34B92EEE4162C5A0DC94F3DA2787E4777F6B45" },
88+ { name = "gleam_http", version = "4.1.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "DD0271B32C356FB684EC7E9F48B1E835D0480168848581F68983C0CC371405D4" },
99+ { name = "gleam_httpc", version = "5.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "C545172618D07811494E97AAA4A0FB34DA6F6D0061FDC8041C2F8E3BE2B2E48F" },
1010+ { name = "gleam_stdlib", version = "0.62.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "DC8872BC0B8550F6E22F0F698CFE7F1E4BDA7312FDEB40D6C3F44C5B706C8310" },
1111+ { name = "gleeunit", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "FDC68A8C492B1E9B429249062CD9BAC9B5538C6FBF584817205D0998C42E1DAC" },
1212+ { name = "hackney", version = "1.25.0", build_tools = ["rebar3"], requirements = ["certifi", "idna", "metrics", "mimerl", "parse_trans", "ssl_verify_fun", "unicode_util_compat"], otp_app = "hackney", source = "hex", outer_checksum = "7209BFD75FD1F42467211FF8F59EA74D6F2A9E81CBCEE95A56711EE79FD6B1D4" },
1313+ { name = "html_parser", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "html_parser", source = "hex", outer_checksum = "EEC0A3891CE99A49A8BB99086A06F56441D2ACF9436CE33ADBE51CE277D2D607" },
1414+ { name = "idna", version = "6.1.1", build_tools = ["rebar3"], requirements = ["unicode_util_compat"], otp_app = "idna", source = "hex", outer_checksum = "92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA" },
1515+ { name = "metrics", version = "1.0.1", build_tools = ["rebar3"], requirements = [], otp_app = "metrics", source = "hex", outer_checksum = "69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16" },
1616+ { name = "mimerl", version = "1.4.0", build_tools = ["rebar3"], requirements = [], otp_app = "mimerl", source = "hex", outer_checksum = "13AF15F9F68C65884ECCA3A3891D50A7B57D82152792F3E19D88650AA126B144" },
1717+ { name = "parse_trans", version = "3.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "parse_trans", source = "hex", outer_checksum = "620A406CE75DADA827B82E453C19CF06776BE266F5A67CFF34E1EF2CBB60E49A" },
1818+ { name = "shellout", version = "1.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "1BDC03438FEB97A6AF3E396F4ABEB32BECF20DF2452EC9A8C0ACEB7BDDF70B14" },
1919+ { name = "splitter", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "splitter", source = "hex", outer_checksum = "128FC521EE33B0012E3E64D5B55168586BC1B9C8D7B0D0CA223B68B0D770A547" },
2020+ { name = "ssl_verify_fun", version = "1.1.7", build_tools = ["mix", "rebar3", "make"], requirements = [], otp_app = "ssl_verify_fun", source = "hex", outer_checksum = "FE4C190E8F37401D30167C8C405EDA19469F34577987C76DDE613E838BBC67F8" },
2121+ { name = "unicode_util_compat", version = "0.7.1", build_tools = ["rebar3"], requirements = [], otp_app = "unicode_util_compat", source = "hex", outer_checksum = "B3A917854CE3AE233619744AD1E0102E05673136776FB2FA76234F3E03B23642" },
2222+]
2323+2424+[requirements]
2525+gleam_hackney = { version = ">= 1.3.1 and < 2.0.0" }
2626+gleam_http = { version = ">= 4.1.1 and < 5.0.0" }
2727+gleam_httpc = { version = ">= 5.0.0 and < 6.0.0" }
2828+gleam_stdlib = { version = ">= 0.44.0 and < 2.0.0" }
2929+gleeunit = { version = ">= 1.0.0 and < 2.0.0" }
3030+html_parser = { version = ">= 1.0.1 and < 2.0.0" }
3131+shellout = { version = ">= 1.7.0 and < 2.0.0" }
3232+splitter = { version = ">= 1.0.0 and < 2.0.0" }
+212
src/condition_overload.gleam
···11+import gleam/http/request
22+import gleam/httpc
33+import gleam/list
44+import gleam/pair
55+import gleam/result
66+import gleam/string
77+import html_parser
88+import shellout
99+import splitter
1010+1111+pub fn main() {
1212+ use shell_result <- result.try(
1313+ shellout.command(
1414+ run: "curl",
1515+ with: [
1616+ "https://wiki.warframe.com/w/Condition_Overload_(Mechanic)?action=edit§ion=7",
1717+ "--silent",
1818+ ],
1919+ in: ".",
2020+ opt: [],
2121+ ),
2222+ )
2323+2424+ let _ =
2525+ shell_result
2626+ |> get_text_area()
2727+ |> result.map(parse_text_area)
2828+ |> result.unwrap([])
2929+ |> list.map(fn(x) { echo x })
3030+ //|> echo
3131+3232+ Ok(Nil)
3333+}
3434+3535+// discards the html and returns only the raw text from the textarea
3636+//
3737+fn get_text_area(html_text: String) -> Result(String, Nil) {
3838+ html_text
3939+ // trim to start of textarea
4040+ |> string.split_once("<textarea")
4141+ |> result.map(pair.second)
4242+ // remove rest of tag
4343+ |> result.try(string.split_once(_, "\">"))
4444+ |> result.map(pair.second)
4545+ // remove stuff after
4646+ |> result.try(string.split_once(_, "</textarea>"))
4747+ |> result.map(pair.first)
4848+}
4949+5050+fn parse_text_area(textarea: String) {
5151+ textarea
5252+ |> string.split("\n")
5353+ |> list.map(string.trim)
5454+ |> process_lines([])
5555+}
5656+5757+type Row {
5858+ Row(
5959+ names: List(String),
6060+ attack: String,
6161+ projectile: String,
6262+ base_damage: String,
6363+ co_bonus_at_100: String,
6464+ co_bonos_rel_base: String,
6565+ math_behavior: String,
6666+ notes: String,
6767+ )
6868+}
6969+7070+// Parse single line entires into Row type
7171+//
7272+// !Weapon!!Attack Name!!Projectile Type!!Attack Unmodded Damage!!Actual CO Damage Bonus at +100%!!CO Damage Bonus Relative To Base Damage!!Math/Behavior Type!!Notes
7373+//
7474+// single name
7575+//
7676+// |{{Weapon|Ambassador}}||Alt-fire Hitscan AoE||AoE||800||600||75%||Adding||Radial hit only receives CO bonus on target directly hit by laser. CO-bonus scales off hitscan damage. AoE does not scale off multishot.
7777+//
7878+// multi name
7979+//
8080+// |{{Weapon|Braton}}/{{Weapon|MK1-Braton|MK1}}/{{Weapon|Braton Prime|Prime}}/{{Weapon|Braton Vandal|Vandal}}||Incarnon Form AoE||AoE||74||70||95%||Adding||Listed values for Braton Prime with inactive Daring Reverie. Radial hit only receives CO bonus on target directly hit by bullet. AoE does not scale off multishot.
8181+//
8282+fn parse_line(line: String) -> Row {
8383+ echo line
8484+ let #(names, rest) = parse_names(line, [])
8585+8686+ let sep = splitter.new(["||"])
8787+8888+ let #(attack, _, rest) = splitter.split(sep, rest)
8989+ let #(projectile, _, rest) = splitter.split(sep, rest)
9090+ let #(base_damage, _, rest) = splitter.split(sep, rest)
9191+ let #(co_bonus_at_100, _, rest) = splitter.split(sep, rest)
9292+ let #(co_bonos_rel_base, _, rest) = splitter.split(sep, rest)
9393+ let #(math_behavior, _, rest) = splitter.split(sep, rest)
9494+ let #(notes, _, _) = splitter.split(sep, rest)
9595+ Row(
9696+ names:,
9797+ attack:,
9898+ projectile:,
9999+ base_damage:,
100100+ co_bonus_at_100:,
101101+ co_bonos_rel_base:,
102102+ math_behavior:,
103103+ notes:,
104104+ )
105105+}
106106+107107+// Parse data line by line from the following formats:
108108+//
109109+// !Weapon!!Attack Name!!Projectile Type!!Attack Unmodded Damage!!Actual CO Damage Bonus at +100%!!CO Damage Bonus Relative To Base Damage!!Math/Behavior Type!!Notes
110110+//
111111+// single name - one line
112112+//
113113+// |{{Weapon|Ambassador}}||Alt-fire Hitscan AoE||AoE||800||600||75%||Adding||Radial hit only receives CO bonus on target directly hit by laser. CO-bonus scales off hitscan damage. AoE does not scale off multishot.
114114+// |-
115115+//
116116+// multi name - one line
117117+//
118118+// |{{Weapon|Braton}}/{{Weapon|MK1-Braton|MK1}}/{{Weapon|Braton Prime|Prime}}/{{Weapon|Braton Vandal|Vandal}}||Incarnon Form AoE||AoE||74||70||95%||Adding||Listed values for Braton Prime with inactive Daring Reverie. Radial hit only receives CO bonus on target directly hit by bullet. AoE does not scale off multishot.
119119+// |-
120120+//
121121+// multi line - single & multi name
122122+//
123123+// |{{Weapon|Evensong}}
124124+// |Charged Radial Attack
125125+// |AoE
126126+// |150
127127+// |0
128128+// |0%
129129+// |N/A
130130+// |Does not apply
131131+// |-
132132+//
133133+// into row type
134134+//
135135+// |-
136136+//
137137+fn process_lines(lines: List(String), acc: List(Row)) -> List(Row) {
138138+ case lines {
139139+ ["|{{Weapon|" <> name_line, ..rest] -> {
140140+ let row = case rest {
141141+ ["|-", ..] -> {
142142+ parse_line(name_line)
143143+ }
144144+ [] | _ -> {
145145+ let #(names, _) = parse_names(name_line, [])
146146+ let row = parse_values_vertical(names, rest)
147147+ row
148148+ }
149149+ }
150150+151151+ process_lines(rest, [row, ..acc])
152152+ }
153153+ [_, ..rest] -> process_lines(rest, acc)
154154+ [] -> acc
155155+ }
156156+}
157157+158158+// multi line - single & multi name
159159+//
160160+// |{{Weapon|Evensong}}
161161+// |Charged Radial Attack
162162+// |AoE
163163+// |150
164164+// |0
165165+// |0%
166166+// |N/A
167167+// |Does not apply
168168+// |-
169169+//
170170+fn parse_values_vertical(names: List(String), lines: List(String)) -> Row {
171171+ let #(attack, rest) = parse_value(lines)
172172+ let #(projectile, rest) = parse_value(rest)
173173+ let #(base_damage, rest) = parse_value(rest)
174174+ let #(co_bonus_at_100, rest) = parse_value(rest)
175175+ let #(co_bonos_rel_base, rest) = parse_value(rest)
176176+ let #(math_behavior, rest) = parse_value(rest)
177177+ let #(notes, _) = parse_value(rest)
178178+179179+ Row(
180180+ names:,
181181+ attack:,
182182+ projectile:,
183183+ base_damage:,
184184+ co_bonus_at_100:,
185185+ co_bonos_rel_base:,
186186+ math_behavior:,
187187+ notes:,
188188+ )
189189+}
190190+191191+// read values one at a time until the next |-
192192+//
193193+fn parse_value(lines: List(String)) {
194194+ case lines {
195195+ ["|-", ..] -> #("", lines)
196196+ ["|" <> value, ..rest] -> #(value, rest)
197197+ [] | [_] | [_, _, ..] -> #("", lines)
198198+ }
199199+}
200200+201201+// process the weapon names
202202+//
203203+fn parse_names(line: String, acc) {
204204+ let sep = splitter.new(["}}/{{Weapon|", "}}/{{Weapon", "}}||", "}}"])
205205+206206+ let #(name, split_by, rest) = splitter.split(sep, line)
207207+208208+ case split_by {
209209+ "}}/{{Weapon|" | "}}/{{Weapon" -> parse_names(rest, [name, ..acc])
210210+ _ -> #([name, ..acc], rest)
211211+ }
212212+}
+13
test/condition_overload_test.gleam
···11+import gleeunit
22+33+pub fn main() -> Nil {
44+ gleeunit.main()
55+}
66+77+// gleeunit test functions end in `_test`
88+pub fn hello_world_test() {
99+ let name = "Joe"
1010+ let greeting = "Hello, " <> name <> "!"
1111+1212+ assert greeting == "Hello, Joe!"
1313+}