-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create Event Parent and Event Child Classes * Issue 20: Update Event Children with scene string instantiation, Create Events Classification script to hold enums for different events and added it to AutoLoader * Issue 20: Add comment for test function * Issue-20: Rename Event classes, remove EventsClassification enum * Issue-20: Update EventBase to have array of different types of events. Update init() as well. * Issue-20: Update EventBase Array holding all Events, Add Unit Test for EventBase
- Loading branch information
1 parent
dfe1838
commit c384093
Showing
6 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
extends Resource | ||
class_name EventBase | ||
|
||
var EVENTS_CLASSIFICATION: Array[Resource] = [EventMob, EventRandom, EventShop, EventHeal] | ||
|
||
var packedScene: String = "" | ||
|
||
# Initialize Event | ||
func _init() -> void: | ||
pass | ||
|
||
func _update_event() -> void: | ||
pass | ||
|
||
func _load_scene() -> Node: | ||
var loadScene: PackedScene = load(packedScene) | ||
return loadScene.instantiate() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extends EventBase | ||
class_name EventHeal | ||
|
||
# @Override | ||
func _init() -> void: | ||
pass | ||
|
||
# @Override | ||
func _update_event() -> void: | ||
print("Updating Heal Event") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extends EventBase | ||
class_name EventMob | ||
|
||
# @Override | ||
func _init() -> void: | ||
pass | ||
|
||
# @Override | ||
func _update_event() -> void: | ||
print("Update Mob") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extends EventBase | ||
class_name EventRandom | ||
|
||
# @Override | ||
func _init() -> void: | ||
pass | ||
|
||
# @Override | ||
func _update_event() -> void: | ||
print("Updating Random Event") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
extends EventBase | ||
class_name EventShop | ||
|
||
# @Override | ||
func _init() -> void: | ||
pass | ||
|
||
# @Override | ||
func _update_event() -> void: | ||
print("Updating shop") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends GutTest | ||
## Test for Event Base and Events | ||
|
||
var eventBase: EventBase = null | ||
|
||
func before_each(): | ||
eventBase = EventBase.new() | ||
|
||
func test_event_base_array_all_types(): | ||
var event0 = eventBase.EVENTS_CLASSIFICATION[0] | ||
assert_eq(event0, EventMob) | ||
|
||
var event1 = eventBase.EVENTS_CLASSIFICATION[1] | ||
assert_eq(event1, EventRandom) | ||
|
||
var event2 = eventBase.EVENTS_CLASSIFICATION[2] | ||
assert_eq(event2, EventShop) | ||
|
||
var event3 = eventBase.EVENTS_CLASSIFICATION[3] | ||
assert_eq(event3, EventHeal) | ||
|