You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

extends Node
const MotionLib = preload("res://scenes/Global/MotionLib.gd")
class PlayerAnimation extends Object:
var animation : String
var hp_change : float
var stamina_change : float
class Round extends Object:
var action: int
var animations : Array[PlayerAnimation]
class RenderReport:
var rounds: Array[Round]
func _init(report : MotionLib.MotionReport):
self.rounds = []
for motion in report.motions:
self.rounds.push_back(self.convertMotion2Round(report.player1, report.player2, motion))
func convertReaction2PlayerAnimation(reaction : MotionLib.Reaction) -> PlayerAnimation:
if reaction == null:
return null
var a = PlayerAnimation.new()
a.animation = reaction.animation
a.hp_change = -reaction.hp_change
return a
func getReaction(motion : MotionLib.Motion) -> MotionLib.Reaction:
if motion is MotionLib.ActionOnOpponent:
return motion.reaction
return null
func convertMotion2PlayerAnimation(motion : MotionLib.Motion) -> PlayerAnimation:
var a = PlayerAnimation.new()
a.animation = motion.animation
a.stamina_change = motion.stamina_change
return a
func convertMotion2Round(lhs : MotionLib.Someone, rhs : MotionLib.Someone, motion : MotionLib.Motion) -> Round:
var round = Round.new()
round.action = 0 if motion.originator == lhs else 1
round.animations.append(self.convertMotion2PlayerAnimation(motion))
var reaction = self.getReaction(motion)
round.animations.append(self.convertReaction2PlayerAnimation(reaction))
if reaction is MotionLib.Counter:
round.animations[0].hp_change = -reaction.damage
return round