Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit test and diagram changes #36

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
9688b9c
Made Pawns visible while selecting
mohithsrao Dec 25, 2020
26008a6
Update main.yml
mohithsrao Dec 26, 2020
e41788d
Corrected Syntax
mohithsrao Dec 26, 2020
55fe301
Corrected syntax
mohithsrao Dec 26, 2020
2e91f5b
Used default build task
mohithsrao Dec 26, 2020
322793e
Updated directory for build task
mohithsrao Dec 26, 2020
2efa79f
Updated build and added release task
mohithsrao Dec 26, 2020
278ad3e
Updated build actions
mohithsrao Dec 26, 2020
3f379ee
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
0bfcdae
Cahnged release notes generation
mohithsrao Dec 26, 2020
f61a7f9
formated the tag as required
mohithsrao Dec 26, 2020
ab3003a
made formating into saparate step
mohithsrao Dec 26, 2020
f970aea
corrected run task
mohithsrao Dec 26, 2020
43fd273
Updated set variable for output
mohithsrao Dec 26, 2020
28cf5a3
corrected variable
mohithsrao Dec 26, 2020
e6aa098
Added params for getting additional change logs
mohithsrao Dec 26, 2020
d3db007
Corrected syntax
mohithsrao Dec 26, 2020
781524d
Included html files to build
mohithsrao Dec 26, 2020
2e47aab
saparated build and release jobs
mohithsrao Dec 26, 2020
1343357
Corrected artifacts for release
mohithsrao Dec 26, 2020
03de2ce
Updated release artifacts paths
mohithsrao Dec 26, 2020
f28f441
corrected yml syntax
mohithsrao Dec 26, 2020
7e19e11
corrected artifact name
mohithsrao Dec 26, 2020
fb2ff82
Added zip files
mohithsrao Dec 26, 2020
4ea4a1e
removed extra path folder
mohithsrao Dec 26, 2020
267c334
changed the artifacts to tar's instead of direct files
mohithsrao Dec 26, 2020
0fd9a75
corrected path for upload
mohithsrao Dec 26, 2020
ccdc833
corrected tar path
mohithsrao Dec 26, 2020
332327e
corrected tar path
mohithsrao Dec 26, 2020
39615d8
removed unnecessary path for tar file
mohithsrao Dec 26, 2020
0eba5bd
corrected artifact name while uploading.
mohithsrao Dec 26, 2020
633f131
asset path correction
mohithsrao Dec 26, 2020
f22f1d1
Updated main release with updated changes
mohithsrao Dec 26, 2020
f784ac0
Updated Build path
mohithsrao Dec 26, 2020
0b26cde
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
bc3ad29
Updated path for build
mohithsrao Dec 26, 2020
7fa82b9
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
02ceeaf
updated export preset names
mohithsrao Dec 26, 2020
f87cd76
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
2efd64a
changed base directory
mohithsrao Dec 26, 2020
aceff8e
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
3b020e1
Removed change directory
mohithsrao Dec 26, 2020
02811f7
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
6051b50
fixed syntax
mohithsrao Dec 26, 2020
c138a2f
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
89afd0c
changed ped location
mohithsrao Dec 26, 2020
a65a224
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
cd821b2
changed tar's to zip files
mohithsrao Dec 26, 2020
d963b4e
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
29bc576
Corrected task name to zip
mohithsrao Dec 26, 2020
090cb40
removed sudo
mohithsrao Dec 26, 2020
8758601
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
78e95ba
changed zip path
mohithsrao Dec 26, 2020
bad6e15
Merge branch 'master' into PawnGoal
mohithsrao Dec 26, 2020
863c35d
Updated badge and redirecting changelog.md file to release Body
mohithsrao Dec 27, 2020
8447d3f
Merge branch 'master' into PawnGoal
mohithsrao Dec 27, 2020
a881fb9
Updated command
mohithsrao Dec 27, 2020
34dc554
Printing md file
mohithsrao Dec 27, 2020
a62c988
Used body_path instead of body
mohithsrao Dec 27, 2020
feed234
Merge branch 'master' into PawnGoal
mohithsrao Dec 30, 2020
e4e9bcc
Added Notification Text
mohithsrao Dec 30, 2020
183b862
Added notification and Unit test for playerto project
mohithsrao Jan 28, 2021
9df3461
Updated diagrams for new systems to be implemented
mohithsrao Jan 28, 2021
55e7672
Updated diagram for opaen class structure
mohithsrao Jan 28, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export.cfg

#Build and Release ignores
Bin/
addons/

#VSCode-specific ignores
.vscode/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an empty line at the end

194 changes: 191 additions & 3 deletions ChoukaBara.drawio

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions ChoukaBaraGame/Scenes/HUD/NotifiationText.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extends Position2D

onready var lable = get_node("Label")
onready var tween = get_node("Tween")
var notificationString = ""

export var tween_duration = 0.5
export var notification_length = 3

func _ready():
lable.text = notificationString
tween.connect("tween_all_completed", self, "_on_Tween_tween_all_completed")

tween.interpolate_property(self, 'scale' , scale ,Vector2(1,1), tween_duration, Tween.TRANS_LINEAR, Tween.EASE_OUT)
tween.interpolate_property(self, 'scale' ,Vector2(1,1), scale , tween_duration, Tween.TRANS_LINEAR, Tween.EASE_IN, notification_length)
tween.start()

func _on_Tween_tween_all_completed():
self.queue_free()
29 changes: 29 additions & 0 deletions ChoukaBaraGame/Scenes/HUD/NotifiationText.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://Scenes/HUD/NotifiationText.gd" type="Script" id=1]

[node name="NotificationText" type="Position2D"]
scale = Vector2( 0.5, 0.5 )
script = ExtResource( 1 )

[node name="Label" type="Label" parent="."]
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
margin_left = -75.0
margin_top = -30.0
margin_right = 75.0
grow_vertical = 0
custom_colors/font_color = Color( 0.976471, 0.219608, 0.0196078, 1 )
custom_colors/font_outline_modulate = Color( 0.988235, 0.988235, 0.988235, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
text = "Test Notification"
align = 1
valign = 1
autowrap = true
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Tween" type="Tween" parent="."]
3 changes: 3 additions & 0 deletions ChoukaBaraGame/Scenes/Player/Pawn.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,6 @@ anims/up = SubResource( 5 )
[node name="Hurtbox" parent="." instance=ExtResource( 4 )]

[node name="StateMachine" parent="." instance=ExtResource( 5 )]

[node name="NotificationRoot" type="Position2D" parent="."]
position = Vector2( 0, -35 )
6 changes: 5 additions & 1 deletion ChoukaBaraGame/Scenes/Player/Player.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]

[ext_resource path="res://Scripts/Player/Player.gd" type="Script" id=1]
[ext_resource path="res://Scenes/Player/HomeBase.tscn" type="PackedScene" id=2]
[ext_resource path="res://Scripts/Player/CheckPlayerTurnValidity.gd" type="Script" id=3]

[sub_resource type="NavigationPolygon" id=1]
resource_local_to_scene = true
Expand All @@ -18,3 +19,6 @@ script = ExtResource( 1 )
navpoly = SubResource( 1 )

[node name="HomeBase" parent="." instance=ExtResource( 2 )]

[node name="CheckPlayerTurnValidity" type="Node" parent="."]
script = ExtResource( 3 )
36 changes: 36 additions & 0 deletions ChoukaBaraGame/Scripts/Player/CheckPlayerTurnValidity.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
extends Node

func CheckPlayerTurnForGara(garaList:Array) -> bool:
var parent = get_parent()
var children = parent.get_children()
var crieteria = funcref(self,"_GetPawns")
var pawnChildren = _filter(children,crieteria)

var canPlayerMovePawn = false
for pawn in pawnChildren:
var canPawnMove = false
var previousGara:int = 0
for n in range(garaList.size()):
if(n != 0):
previousGara = garaList[n-1]
var currentGara:int = garaList[n]
var garaToCheck = previousGara + currentGara
canPawnMove = (pawn as Pawn).canMoveSelectedTurn(garaToCheck,false)
if(canPawnMove):
canPlayerMovePawn = true
break

return canPlayerMovePawn

func _GetPawns(child) -> bool:
return child is Pawn;

func _filter(list: Array, matches_criteria: FuncRef) -> Array:
# Usually better to add filtered elements to new array
# because removing elements while iterating over a list
# causes weird behaviour
var filtered: Array = []
for element in list:
if matches_criteria.call_func(element):
filtered.append(element)
return filtered
31 changes: 24 additions & 7 deletions ChoukaBaraGame/Scripts/Player/Pawn.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ signal pawn_unselected

signal movement_round_complete

var notification_scene = preload("res://Scenes/HUD/NotifiationText.tscn")

onready var tween : Tween = $Tween
onready var ray : RayCast2D = $RayCast2D
onready var animationPlayer : AnimationPlayer = $AnimationPlayer
Expand All @@ -15,6 +17,7 @@ onready var hitboxCollision = $Hitbox/CollisionShape2D
onready var hitbox = $Hitbox
onready var hurtbox = $Hurtbox
onready var hurtboxCollision = $Hurtbox/CollisionShape2D
onready var notificationRoot = $NotificationRoot

var pawnHit = false
var speed : int = 2
Expand Down Expand Up @@ -75,7 +78,7 @@ func resetAnimation() -> void:

func select_pawn(pawn:Pawn) -> void:
PlayerInfo.active_player.selectedPawn = pawn
sprite.scale = Vector2(1.5,1.5)
sprite.scale = Vector2(1.5,1.5)
emit_signal("pawn_selected")

func unselect_pawn() -> void:
Expand Down Expand Up @@ -105,9 +108,23 @@ func _on_hurtbox_area_entered(areaEntered:Area2D):
PlayerInfo.active_player.canEnterInnerCircle = true
PlayerInfo.active_player.needsReRoll = true

func canMoveSelectedTurn(gara:int)-> bool:
if(PlayerInfo.active_player.canEnterInnerCircle):
return true;
elif (currentLocation + gara < GameUtility.distanceToInnerCircle):
return true
return false
func canMoveSelectedTurn(gara:int, showNotification: bool = true)-> bool:
var positionToBeMoved = currentLocation + gara
var notification = ""
var result = true
if(not PlayerInfo.active_player.canEnterInnerCircle && not (positionToBeMoved <= GameUtility.distanceToGoal)):
notification = "Cannot enter goal as steps is greaer than goal distance"
result = false
elif (not (positionToBeMoved < GameUtility.distanceToInnerCircle)):
notification = "Cannot enter inner circle as Player HIT not performed"
result = false

if (showNotification && not notification.empty()):
showNotification(notification)

return result

func showNotification(notificationText:String):
var notification_instance = notification_scene.instance()
notification_instance.notificationString = notificationText
notificationRoot.add_child(notification_instance)
13 changes: 10 additions & 3 deletions ChoukaBaraGame/Scripts/StateMachine/GameStateMachine/MovePawn.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ extends IState

func enter(logic_root):
.enter(logic_root)
if(not PlayerInfo.garaList.empty() && PlayerInfo.active_player.selectedPawn.canMoveSelectedTurn(PlayerInfo.garaList.front())):
if(canEnter()):
yield(GameUtility.select_destination(PlayerInfo.garaList.pop_front(),PlayerInfo.active_player.selectedPawn,true),"completed")
yield(get_tree(), "idle_frame")
# else:
# Update HUD to display error for not able to enter Inner Circle

emit_signal("finished","SelectPawn")

Expand All @@ -15,3 +13,12 @@ func exit():
PlayerInfo.active_player.selectedPawn.resetAnimation()
PlayerInfo.active_player.selectedPawn.call_deferred("enableHitBox",false)
PlayerInfo.active_player.selectedPawn.unselect_pawn()

func canEnter() -> bool:
var activePlayer = PlayerInfo.active_player
var canSelectedPawnMoveResult = activePlayer.selectedPawn.canMoveSelectedTurn(PlayerInfo.garaList.front())
var canPlayerMoveAnyPawnResult = activePlayer.canPlayerMoveAnyPawn(PlayerInfo.garaList)
if(not PlayerInfo.garaList.empty() && (canSelectedPawnMoveResult as bool)):
return true

return false
34 changes: 34 additions & 0 deletions ChoukaBaraGame/UnitTests/PlayerTests/test_player.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
extends "res://addons/gut/test.gd"

var PlayerScene: PackedScene = preload("res://Scenes/Player/Player.tscn")
var player = PlayerScene.instance()

func before_all():
gut.p("Runs once before all tests")
var child = add_child(player)
PlayerInfo.active_player = player

func before_each():
gut.p("Runs before each test.")

func after_each():
gut.p("Runs after each test.")

func after_all():
gut.p("Runs once after all tests")
player.free()

func test_player_is_not_null():
assert_not_null(player)

func test_CheckScript_is_not_null():
var checkScript = player.get_node("CheckPlayerTurnValidity").get_script()
assert_not_null(checkScript)

func test_player_gara_should_fail_when_no_pawn_can_move():
var garaList = [8,8,8,8,8,8,8,8,8,2]
var checkNodeScript = player.get_node("CheckPlayerTurnValidity")

var result = checkNodeScript.CheckPlayerTurnForGara(garaList)

assert_false(result,"Should pass when no pawns are able to move")
16 changes: 16 additions & 0 deletions ChoukaBaraGame/UnitTests/UnitTestMaster.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://addons/gut/plugin_control.gd" type="Script" id=1]

[node name="Gut" type="Control"]
margin_right = 740.0
margin_bottom = 250.0
rect_min_size = Vector2( 740, 250 )
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
_run_on_load = true
_should_maximize = true
_include_subdirectories = true
_directory1 = "res://UnitTests"
2 changes: 2 additions & 0 deletions ChoukaBaraGame/debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[1230/191809.452:ERROR:settings.cc(325)] Settings version is not 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the debug.log and maybe add this in .gitignore

[0102/130853.266:ERROR:settings.cc(325)] Settings version is not 1
5 changes: 5 additions & 0 deletions ChoukaBaraGame/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ GameUtility="*res://Scripts/Game/GameUtility.gd"

[debug]

gdscript/warnings/exclude_addons=false
gdscript/completion/autocomplete_setters_and_getters=true
gdscript/warnings/unused_class_variable=true
gdscript/warnings/unsafe_property_access=true
Expand All @@ -82,6 +83,10 @@ window/size/resizable=false
window/stretch/mode="2d"
window/stretch/aspect="keep"

[editor_plugins]

enabled=PoolStringArray( "gut" )

[input]

right={
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ The game to be created is an old indian board game called Chouka-Bara

The game is going to be in 2D and built in the godot Game engine

This project uses GUT(Godot Unit Test) plugin fom the Asset Liberary, Install The Plugin from AssetLib after loading the project to run Unit Tests

Reference Project

https://kidscancode.org/godot_recipes/2d/grid_movement/
Expand Down