Proper module support #4

Merged
LunarTides merged 10 commits from modules into main 2024-03-25 14:04:15 +00:00
LunarTides commented 2024-03-14 18:59:01 +00:00 (Migrated from github.com)

Closes #3

I was a little bit premature to close #3 by cb790d7.

Turned most Enums into Array[StringName] to be able to add more at run-time.

Known regressions:

Todo:

  • Finish taunt keyword.
  • Resolve review comments.
Closes #3 I was a little bit premature to close #3 by cb790d7. Turned most Enums into `Array[StringName]` to be able to add more at run-time. Known regressions: - [x] `The Coin` starts in the left of the player's hand. - [x] https://github.com/LunarTides/Hearthstone.gd/pull/4#discussion_r1525862711 - [x] Visual stuff is very slow, laggy, and unresponsive. Todo: - [ ] Finish taunt keyword. - [ ] Resolve review comments.
LunarTides (Migrated from github.com) reviewed 2024-03-14 19:16:02 +00:00
LunarTides (Migrated from github.com) left a comment

I did a very rough pass of the code. Make sure everything is stable before merging.

Also rename the commits before merging. (Fixed)

I did a very rough pass of the code. Make sure everything is stable before merging. ~Also rename the commits before merging.~ (Fixed)
@ -1,19 +1,22 @@
[gd_scene load_steps=4 format=3 uid="uid://c8kcj58hy41o0"]
LunarTides (Migrated from github.com) commented 2024-03-14 19:02:33 +00:00

The taunt is just for testing. Remove before merging.

keywords = Array[StringName]([])
The taunt is just for testing. Remove before merging. ```suggestion keywords = Array[StringName]([]) ```
@ -10,3 +10,3 @@
card.add_ability(Card.Ability.CAST, cast)
card.add_ability(&"Cast", cast)
LunarTides (Migrated from github.com) commented 2024-03-14 19:03:28 +00:00

Using StringName instead of an enum makes it a lot easier to mistype. Figure out if there is some way to prevent that.

Using `StringName` instead of an enum makes it a lot easier to mistype. Figure out if there is some way to prevent that.
LunarTides (Migrated from github.com) commented 2024-03-14 19:07:12 +00:00

Maybe instead of passing a handler, we could pass self:

	Modules.register_hooks(self)

And then in modules.gd:

def register_hooks(module: Node):
    # ...
    module["%s_hook" % what.to_snake_case()].callv(info)
    # ...
Maybe instead of passing a handler, we could pass `self`: ```suggestion Modules.register_hooks(self) ``` And then in `modules.gd`: ```gdscript def register_hooks(module: Node): # ... module["%s_hook" % what.to_snake_case()].callv(info) # ... ```
@ -90,6 +90,94 @@ enum {
LunarTides (Migrated from github.com) commented 2024-03-14 19:09:29 +00:00

The rarities will probably get their own module/modules. I just have them here for now, but in the future we would want to split them.

This applies to most stuff here. Splitting them out of core would be difficult though...

The rarities will probably get their own module/modules. I just have them here for now, but in the future we would want to split them. This applies to most stuff here. Splitting them out of core would be difficult though...
@ -37,1 +37,4 @@
blueprints.sort_custom(func(a: Blueprint, b: Blueprint) -> bool:
if not a.id or not b.id:
return true
LunarTides (Migrated from github.com) commented 2024-03-14 19:11:26 +00:00

I'm not sure if this is necessary but it was giving me a lot of errors (though adding this didn't fix it).

Try to remove and see if it works.

I'm not sure if this is necessary but it was giving me a lot of errors (though adding this didn't fix it). Try to remove and see if it works.
@ -264,2 +266,4 @@
Multiplayer.create_blueprint_from_id.rpc(2, player2.id, &"Hand", player2.hand.size())
LunarTides (Migrated from github.com) commented 2024-03-14 19:12:20 +00:00

I wonder if it would be possible to put the code in Packet.send here.

I wonder if it would be possible to put the code in `Packet.send` here.
LunarTides (Migrated from github.com) commented 2024-03-14 19:13:44 +00:00

We need to make sure that the StringName info stuff is validated everywhere.

We need to make sure that the `StringName` info stuff is validated everywhere.
LunarTides (Migrated from github.com) commented 2024-03-14 19:14:19 +00:00

This is unrelated, I just spotted it.

This is unrelated, I just spotted it.
LunarTides (Migrated from github.com) commented 2024-03-14 19:14:56 +00:00

Just in case any modules want to extend these for whatever reason.

Just in case any modules want to extend these for whatever reason.
LunarTides (Migrated from github.com) reviewed 2024-03-14 19:19:11 +00:00
LunarTides (Migrated from github.com) commented 2024-03-14 19:19:11 +00:00

In fact, maybe every module should inherit some Module class that does this in _ready automatically. Then it would be less work and code for the individual modules.

In fact, maybe every module should inherit some `Module` class that does this in `_ready` automatically. Then it would be less work and code for the individual modules.
LunarTides (Migrated from github.com) reviewed 2024-03-15 06:59:13 +00:00
LunarTides (Migrated from github.com) commented 2024-03-15 06:59:13 +00:00

I think it would be better for users to specify themselves. It would also be different from how cards do it, since cards do something similar with abilities.

I think it would be better for users to specify themselves. It would also be different from how cards do it, since cards do something similar with abilities.
LunarTides (Migrated from github.com) reviewed 2024-03-15 07:49:29 +00:00
LunarTides (Migrated from github.com) left a comment

I did a pass of the two newest commits. It looks good, but there are some concerns. This will likely be the final review, since i need to merge this soon.

I did a pass of the two newest commits. It looks good, but there are some concerns. This will likely be the final review, since i need to merge this soon.
@ -17,3 +19,3 @@
collectible = true
id = 3
tribes = Array[int]([0])
tribes = Array[StringName]([&"None"])
LunarTides (Migrated from github.com) commented 2024-03-15 07:38:31 +00:00

Is this good? This would be a lot better in Godot 4.3 because of typed dictionaries.

Is this good? This would be a lot better in Godot 4.3 because of typed dictionaries.
@ -0,0 +1,28 @@
extends Node
LunarTides (Migrated from github.com) commented 2024-03-15 07:43:04 +00:00

This doesn't do anything yet, but it might in the future. Maybe it would be a good idea to not do this until needed?

This doesn't do anything yet, but it might in the future. Maybe it would be a good idea to not do this until needed?
@ -0,0 +2,4 @@
#region Internal Functions
func _ready() -> void:
LunarTides (Migrated from github.com) commented 2024-03-15 07:44:59 +00:00

Using modules directly is VERY BAD. The only exception is when using a base module inside of a child module. E.g. Using KeywordModule in the Taunt module, like we are doing here.

Using modules directly is **_VERY BAD_**. The only exception is when using a base module inside of a child module. E.g. Using `KeywordModule` in the `Taunt` module, like we are doing here.
LunarTides (Migrated from github.com) commented 2024-03-15 07:45:50 +00:00

This is very ugly. Figure out if there is a better way of doing this.

This is very ugly. Figure out if there is a better way of doing this.
@ -0,0 +1,84 @@
extends Node
LunarTides (Migrated from github.com) commented 2024-03-15 07:37:47 +00:00

For some reason, rarities show for player 2 even if the rarity is Free?

For some reason, rarities show for player 2 even if the rarity is `Free`?
LunarTides (Migrated from github.com) commented 2024-03-15 07:39:54 +00:00

We register all rarities in the base rarity module since individual rarities aren't unique enough to warrent their own seperate modules.

We register all rarities in the base rarity module since individual rarities aren't unique enough to warrent their own seperate modules.
@ -0,0 +46,4 @@
# Rarity Color
if not card.modules.get("rarities"):
assert(false, "'%s' (%d) doesn't have a rarity." % [card.name, card.id])
LunarTides (Migrated from github.com) commented 2024-03-15 07:40:50 +00:00

Is it a good idea to warn about not using a module? I guess using a disabled module isn't really a problem, so it should be fine.

Is it a good idea to warn about not using a module? I guess using a disabled module isn't really a problem, so it should be fine.
@ -26,7 +26,17 @@ Packet="*res://scripts/multiplayer/packet.gd"
Anticheat="*res://scripts/multiplayer/anticheat.gd"
LunarTides (Migrated from github.com) commented 2024-03-15 07:47:50 +00:00

Don't expose RarityModule since it doesn't have any children? Maybe?

Don't expose `RarityModule` since it doesn't have any children? Maybe?
@ -28,2 +28,3 @@
Modules="*res://scripts/modules.gd"
TauntModule="res://modules/taunt/taunt.gd"
KeywordModule="*res://modules/keyword/keyword.gd"
KeywordTauntModule="*res://modules/keyword/taunt/taunt.gd"
LunarTides (Migrated from github.com) commented 2024-03-15 07:47:14 +00:00

KeywordModule and all base modules need to be global variables to be used by child modules. There should be something to discourage referencing modules directly somewhere for other users, but it's fine for now.

`KeywordModule` and all base modules need to be global variables to be used by child modules. There should be something to discourage referencing modules directly somewhere for other users, but it's fine for now.
@ -9,0 +37,4 @@
CARD_SUMMON,
CARD_TWEEN_START,
CARD_UPDATE,
DAMAGE,
LunarTides (Migrated from github.com) commented 2024-03-15 07:42:18 +00:00

Remove verbose printing since it was spamming the console with ~10,000 lines of garbage because of the "Update Card" request.

Remove verbose printing since it was spamming the console with ~10,000 lines of garbage because of the "Update Card" request.
LunarTides (Migrated from github.com) reviewed 2024-03-15 07:58:21 +00:00
@ -0,0 +1,84 @@
extends Node
LunarTides (Migrated from github.com) commented 2024-03-15 07:58:21 +00:00

Also, the rarity mesh needs to be split from the core card model.

Also, the rarity mesh needs to be split from the core card model.
LunarTides (Migrated from github.com) reviewed 2024-03-17 18:31:39 +00:00
LunarTides (Migrated from github.com) commented 2024-03-15 19:39:15 +00:00

Should keywords be arrays or dictionaries?

Should keywords be arrays or dictionaries?
LunarTides (Migrated from github.com) reviewed 2024-03-17 19:22:04 +00:00
@ -0,0 +1,84 @@
extends Node
LunarTides (Migrated from github.com) commented 2024-03-17 19:22:04 +00:00

This turned out to be a much bigger problem than I thought...

This turned out to be a much bigger problem than I thought...
LunarTides (Migrated from github.com) reviewed 2024-03-18 09:45:27 +00:00
@ -26,7 +26,17 @@ Packet="*res://scripts/multiplayer/packet.gd"
Anticheat="*res://scripts/multiplayer/anticheat.gd"
LunarTides (Migrated from github.com) commented 2024-03-18 09:45:27 +00:00
Superseded by https://github.com/LunarTides/Hearthstone.gd/pull/4#discussion_r1525871216
LunarTides (Migrated from github.com) reviewed 2024-03-25 14:01:40 +00:00
@ -264,2 +266,4 @@
Multiplayer.create_blueprint_from_id.rpc(2, player2.id, &"Hand", player2.hand.size())
LunarTides (Migrated from github.com) commented 2024-03-25 14:01:40 +00:00

No longer applies as of 517a342291

No longer applies as of 517a3422919a9c2b2d298985872126c19dc9ca2c
LunarTides commented 2024-03-25 14:04:10 +00:00 (Migrated from github.com)

Merging prematurely to just get this merged.

Merging prematurely to just get this merged.
LunarTides (Migrated from github.com) reviewed 2024-04-23 08:56:54 +00:00
@ -10,3 +10,3 @@
card.add_ability(Card.Ability.CAST, cast)
card.add_ability(&"Cast", cast)
LunarTides (Migrated from github.com) commented 2024-04-23 08:56:54 +00:00

Making them capitalized makes it worse. Maybe think about making it lowercase / uppercase.

Making them capitalized makes it worse. Maybe think about making it lowercase / uppercase.
Sign in to join this conversation.
No description provided.