<commit_before>package game.actorPerPlayer

import akka.actor.{Actor, ActorRef}
import akka.actor.Actor.Receive
import core.CoreMessage.Command
import game.GameEvent.{Angle, Player, PlayerData, PlayerMessage, PlayersUpdate, Tick, Vector}
import game.GameEvent.PlayerData.newOne
import play.api.libs.json.Json
import game.Formatters._

/**
  * Created by vannasay on 27/10/16.
  */
class ActorPerPlayer(id: String, playerActorRef: ActorRef) extends Actor{
  val rand = scala.util.Random
  var player = Player(newOne(id, rand), playerActorRef)
  var message = ""

  override def receive: Receive = {
    case Command(id, command) => {
      player = player.setCommand(command)
    }
    case Tick() => {
      player = Player(physic(player.data), player.actor)
      updateMessage
      notifyPlayer
    };
  }

  def physic(data: PlayerData): PlayerData = {
    if(data.lastCommand != null) {
      val jsonObject = Json.parse(data.lastCommand)
      val mouse_x = (jsonObject \ "mouse" \ "x").as[Double]
      val mouse_y = (jsonObject \ "mouse" \ "y").as[Double]
      val direction2go = Vector(mouse_x, mouse_y) - data.p.head
      var newAngle  = 0.0
<commit_msg>Fix creation of playerData<commit_after>package game.actorPerPlayer

import akka.actor.{Actor, ActorRef}
import akka.actor.Actor.Receive
import core.CoreMessage.Command
import game.GameEvent.{Angle, Player, PlayerData, PlayerMessage, PlayersUpdate, Tick, Vector}
import game.GameEvent.PlayerData.newOne
import play.api.libs.json.Json
import game.Formatters._

/**
  * Created by vannasay on 27/10/16.
  */
class ActorPerPlayer(id: String, playerActorRef: ActorRef) extends Actor{
  val rand = scala.util.Random
  var player = Player( PlayerData(id, Vector(0, 0) :: List.empty[Vector], 50, rand.nextDouble(), 10, 10, Array(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255)), null), playerActorRef)
  var message = ""

  override def receive: Receive = {
    case Command(id, command) => {
      player = player.setCommand(command)
    }
    case Tick() => {
      player = Player(physic(player.data), player.actor)
      updateMessage
      notifyPlayer
    };
  }

  def physic(data: PlayerData): PlayerData = {
    if(data.lastCommand != null) {
      val jsonObject = Json.parse(data.lastCommand)
      val mouse_x = (jsonObject \ "mouse" \ "x").as[Double]
      val mouse_y = (jsonObject \ "mouse" \ "y").as[Double]
      val direction2go = Vector(mouse_x, mouse_y) - data.p.head
      var newAngle  = 0.0

{'fraction_non_alphanumeric': 0.12575574365175332, 'fraction_numerical': 0.014107214832728738, 'mean_word_length': 3.6392523364485982, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3523537', 'n_tokens_mistral': 837, 'n_tokens_neox': 795, 'n_words': 190}