2020-10-14 14:48:38 +02:00
|
|
|
extends Control
|
2020-10-13 14:16:36 +02:00
|
|
|
|
2020-10-13 17:08:37 +02:00
|
|
|
var cards = [
|
2020-10-22 14:01:08 +02:00
|
|
|
# {
|
|
|
|
# "command": 'git add .',
|
|
|
|
# "arg_number": 0,
|
|
|
|
# "description": "Add all files in the working directory to the index.",
|
|
|
|
# "energy": 1
|
|
|
|
# },
|
|
|
|
#
|
|
|
|
# {
|
|
|
|
# "command": 'touch "file$RANDOM"',
|
|
|
|
# "arg_number": 0,
|
|
|
|
# "description": "Create a new file.",
|
|
|
|
# "energy": 2
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# "command": 'git checkout -b "$RANDOM"',
|
|
|
|
# "arg_number": 0,
|
|
|
|
# "description": "Create a new branch and switch to it.",
|
|
|
|
# "energy": 2
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# "command": 'git merge',
|
|
|
|
# "arg_number": 1,
|
|
|
|
# "description": "Merge specified commit into HEAD.",
|
|
|
|
# "energy": 1
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# "command": 'git commit --allow-empty -m "$RANDOM"',
|
|
|
|
# "arg_number": 0,
|
|
|
|
# "description": "Add a new commit under HEAD.",
|
|
|
|
# "energy": 1
|
|
|
|
# },
|
2020-10-15 15:22:38 +02:00
|
|
|
{
|
2020-10-22 14:01:08 +02:00
|
|
|
"command": 'git checkout',
|
2020-10-15 15:22:38 +02:00
|
|
|
"arg_number": 1,
|
2020-10-22 14:01:08 +02:00
|
|
|
"description": "Travel to a commit!",
|
|
|
|
#"description": "Point HEAD to a branch or commit, and update the index and the working directory.",
|
2020-10-15 15:22:38 +02:00
|
|
|
"energy": 1
|
|
|
|
},
|
2020-10-15 16:11:02 +02:00
|
|
|
{
|
2020-10-22 14:01:08 +02:00
|
|
|
"command": 'git add .; git commit',
|
2020-10-15 16:11:02 +02:00
|
|
|
"arg_number": 0,
|
2020-10-22 14:01:08 +02:00
|
|
|
"description": "Make a new commit!",
|
2020-10-22 17:27:54 +02:00
|
|
|
"energy": 1
|
|
|
|
},
|
2020-10-22 22:19:30 +02:00
|
|
|
# {
|
|
|
|
# "command": 'git branch new',
|
|
|
|
# "arg_number": 1,
|
|
|
|
# "description": "Create a new timeline.",
|
|
|
|
# "energy": 1
|
|
|
|
# },
|
2020-10-15 15:22:38 +02:00
|
|
|
{
|
2020-10-22 14:01:08 +02:00
|
|
|
"command": 'git merge',
|
2020-10-15 15:22:38 +02:00
|
|
|
"arg_number": 1,
|
2020-10-22 14:01:08 +02:00
|
|
|
"description": "Merge the specified timeline into yours.",
|
2020-10-15 15:22:38 +02:00
|
|
|
"energy": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"command": 'git rebase',
|
|
|
|
"arg_number": 1,
|
2020-10-22 14:01:08 +02:00
|
|
|
"description": "Put the events in your current timeline on top of the specified one.",
|
2020-10-15 15:22:38 +02:00
|
|
|
"energy": 1
|
|
|
|
},
|
2020-10-22 14:36:59 +02:00
|
|
|
{
|
|
|
|
"command": 'git pull',
|
|
|
|
"arg_number": 0,
|
|
|
|
"description": "Get timelines from a colleague.",
|
|
|
|
"energy": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"command": 'git push',
|
|
|
|
"arg_number": 0,
|
|
|
|
"description": "Give timelines to a colleague.",
|
|
|
|
"energy": 1
|
|
|
|
},
|
2020-10-22 22:19:30 +02:00
|
|
|
{
|
|
|
|
"command": 'git rebase -i',
|
|
|
|
"arg_number": 1,
|
|
|
|
"description": "Make changes to the events in your current timeline, back to the commit you drag this to.",
|
|
|
|
"energy": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"command": 'git reset --hard',
|
|
|
|
"arg_number": 1,
|
|
|
|
"description": "Reset current label to the specified commit.",
|
|
|
|
"energy": 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"command": 'git cherry-pick',
|
|
|
|
"arg_number": 1,
|
|
|
|
"description": "Repeat the specified action on top of your current timeline.",
|
|
|
|
"energy": 1
|
|
|
|
},
|
2020-10-22 14:01:08 +02:00
|
|
|
# {
|
|
|
|
# "command": 'git update-ref -d',
|
|
|
|
# "arg_number": 1,
|
|
|
|
# "description": "Delete a ref.",
|
|
|
|
# "energy": 1
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# "command": 'git reflog expire --expire=now --all; git prune',
|
|
|
|
# "arg_number": 0,
|
|
|
|
# "description": "Delete all unreferenced objects.",
|
|
|
|
# "energy": 1
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# "command": 'git rebase',
|
|
|
|
# "arg_number": 1,
|
|
|
|
# "description": "Rebase current branch on top of specified commit.",
|
|
|
|
# "energy": 1
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# "command": 'git push -f',
|
|
|
|
# "arg_number": 0,
|
|
|
|
# "description": "Push current branch to the remote, overwriting existing commits. Will make everyone angry.",
|
|
|
|
# "energy": 3
|
|
|
|
# },
|
|
|
|
# {
|
|
|
|
# "command": 'git pull',
|
|
|
|
# "arg_number": 0,
|
|
|
|
# "description": "Pull current branch from the remote.",
|
|
|
|
# "energy": 2
|
|
|
|
# },
|
2020-10-13 17:08:37 +02:00
|
|
|
]
|
|
|
|
|
2020-10-13 14:16:36 +02:00
|
|
|
func _ready():
|
2020-10-14 00:57:30 +02:00
|
|
|
# var path = game.tmp_prefix_inside+"/repos/sandbox/"
|
|
|
|
# helpers.careful_delete(path)
|
|
|
|
#
|
|
|
|
# game.global_shell.run("mkdir " + path)
|
|
|
|
# game.global_shell.cd(path)
|
|
|
|
# game.global_shell.run("git init")
|
|
|
|
# game.global_shell.run("git remote add origin ../remote")
|
|
|
|
# $Repository.path = path
|
|
|
|
# $Terminal.repository = $Repository
|
|
|
|
#
|
|
|
|
# var path2 = game.tmp_prefix_inside+"/repos/remote/"
|
|
|
|
# helpers.careful_delete(path2)
|
|
|
|
#
|
|
|
|
# game.global_shell.run("mkdir " + path2)
|
|
|
|
# game.global_shell.cd(path2)
|
|
|
|
# game.global_shell.run("git init")
|
|
|
|
# game.global_shell.run("git config receive.denyCurrentBranch ignore")
|
|
|
|
# $RepositoryRemote.path = path2
|
2020-10-13 17:08:37 +02:00
|
|
|
|
2020-10-13 18:13:42 +02:00
|
|
|
redraw_all_cards()
|
2020-10-13 18:58:30 +02:00
|
|
|
arrange_cards()
|
2020-10-15 16:41:42 +02:00
|
|
|
pass
|
2020-10-13 14:16:36 +02:00
|
|
|
|
2020-10-15 15:53:23 +02:00
|
|
|
func _process(delta):
|
|
|
|
if $Energy:
|
|
|
|
$Energy.text = str(game.energy)
|
|
|
|
|
2020-10-14 00:57:30 +02:00
|
|
|
#func _update_repo():
|
|
|
|
# $Repository.update_everything()
|
|
|
|
# $RepositoryRemote.update_everything()
|
2020-10-13 17:29:24 +02:00
|
|
|
|
|
|
|
func draw_rand_card():
|
2020-10-15 15:53:23 +02:00
|
|
|
var deck = []
|
|
|
|
|
|
|
|
for card in cards:
|
|
|
|
deck.push_back(card)
|
|
|
|
|
|
|
|
# We want a lot of commit and checkout cards!
|
|
|
|
for i in range(5):
|
|
|
|
deck.push_back(cards[0])
|
|
|
|
deck.push_back(cards[1])
|
|
|
|
|
|
|
|
var card = deck[randi() % deck.size()]
|
2020-10-15 16:11:02 +02:00
|
|
|
draw_card(card)
|
|
|
|
|
|
|
|
func draw_card(card):
|
2020-10-26 19:15:47 +01:00
|
|
|
var new_card = preload("res://scenes/card.tscn").instance()
|
2020-10-15 16:11:02 +02:00
|
|
|
|
2020-10-13 17:29:24 +02:00
|
|
|
new_card.command = card.command
|
|
|
|
new_card.arg_number = card.arg_number
|
2020-10-14 00:27:37 +02:00
|
|
|
new_card.description = card.description
|
2020-10-15 16:11:02 +02:00
|
|
|
new_card.energy = 0 #card.energy
|
2020-10-14 14:48:38 +02:00
|
|
|
new_card.position = Vector2(rect_size.x, rect_size.y*2)
|
2020-10-13 17:29:24 +02:00
|
|
|
add_child(new_card)
|
2020-10-13 18:58:30 +02:00
|
|
|
arrange_cards()
|
2020-10-13 17:29:24 +02:00
|
|
|
|
2020-10-13 18:58:30 +02:00
|
|
|
func arrange_cards():
|
2020-10-14 00:04:47 +02:00
|
|
|
var t = Timer.new()
|
|
|
|
t.wait_time = 0.05
|
|
|
|
add_child(t)
|
|
|
|
t.start()
|
|
|
|
yield(t, "timeout")
|
|
|
|
|
2020-10-13 18:58:30 +02:00
|
|
|
var amount_cards = get_tree().get_nodes_in_group("cards").size()
|
2020-10-14 00:46:41 +02:00
|
|
|
var total_angle = min(50, 45.0/7*amount_cards)
|
2020-10-13 18:58:30 +02:00
|
|
|
var angle_between_cards = 0
|
|
|
|
if amount_cards > 1:
|
|
|
|
angle_between_cards = total_angle / (amount_cards-1)
|
2020-10-14 00:04:47 +02:00
|
|
|
|
2020-10-13 18:58:30 +02:00
|
|
|
var current_angle = -total_angle/2
|
|
|
|
for card in get_tree().get_nodes_in_group("cards"):
|
2020-10-14 14:48:38 +02:00
|
|
|
var target_position = Vector2(rect_size.x/2, rect_size.y + 1500)
|
2020-10-14 00:04:47 +02:00
|
|
|
var target_rotation = current_angle
|
2020-10-13 18:58:30 +02:00
|
|
|
var translation_vec = Vector2(0,-1500).rotated(current_angle/180.0*PI)
|
2020-10-14 00:04:47 +02:00
|
|
|
target_position += translation_vec
|
2020-10-13 18:58:30 +02:00
|
|
|
current_angle += angle_between_cards
|
2020-10-14 00:04:47 +02:00
|
|
|
card._home_position = target_position
|
2020-10-15 15:02:43 +02:00
|
|
|
card._home_rotation = target_rotation
|
2020-10-14 00:04:47 +02:00
|
|
|
|
|
|
|
var tween = Tween.new()
|
|
|
|
tween.interpolate_property(card, "position", card.position, target_position, 0.5, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
|
|
|
|
tween.interpolate_property(card, "rotation_degrees", card.rotation_degrees, target_rotation, 0.5, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
|
|
|
|
add_child(tween)
|
|
|
|
tween.start()
|
2020-10-13 18:58:30 +02:00
|
|
|
|
2020-10-13 18:13:42 +02:00
|
|
|
func redraw_all_cards():
|
2020-10-15 15:53:23 +02:00
|
|
|
game.energy = 5
|
2020-10-15 16:11:02 +02:00
|
|
|
|
2020-10-13 18:13:42 +02:00
|
|
|
for card in get_tree().get_nodes_in_group("cards"):
|
|
|
|
card.queue_free()
|
2020-10-26 18:56:35 +01:00
|
|
|
|
2020-10-15 16:11:02 +02:00
|
|
|
for card in cards:
|
|
|
|
draw_card(card)
|
2020-10-15 16:41:42 +02:00
|
|
|
|
|
|
|
func add_card(command):
|
|
|
|
draw_card({"command": command, "description": "", "arg_number": 0, "energy": 0})
|