/usr/share/blobby/rules.lua is in blobby-data 1.0~rc3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | -- most simple ruleset: for each mistake, the opponent gets a point
-- includes comments for documentation purposes
-- rules.lua doc
-- function OnMistake
-- IMPLEMENTED BY RULES.lua
-- called when a player makes a mistake
-- when this function is called, servinglayer() returns which player has
-- served (so it is not neccesarily the enemy of the player who made the mistake)
-- param: player - player who made the mistake
-- return: none
-- when a player makes a mistake, the other one gets a point if he was the serving player
function OnMistake(player)
-- function opponent
-- PREDEFINED
-- param: player - player of whom you want to get the opponent
-- return: opponent of the player, so, for LEFT_PLAYER, RIGHT_PLAYER is returned and vice-versa
-- function servingplayer
-- PREDEFINED
-- param: none
-- return: which player has served
if( opponent(player) == servingplayer() ) then
-- function score
-- PREDEFINED
-- param: player - player who gets a point
-- return: none
score(opponent(player))
end
end
-- function IsWinning
-- IMPLEMENTED BY rules.lua
-- called when it is determined whether a player has won
-- params: lscore: score of left player
-- rscore: score of right player
-- return: whether a player has won
function IsWinning(lscore, rscore)
-- constant SCORE_TO_WIN: number of points for a player to win
if lscore >= SCORE_TO_WIN and lscore >= rscore + 2 then
return true
end
if rscore >= SCORE_TO_WIN and rscore >= lscore + 2 then
return true
end
return false
end
-- function OnBallHitsPlayer
-- IMPLEMENTEDBY rules.lua
-- called when a valid collision between a player and the ball happens.
-- params: player: The player that hit the ball
-- touches: Number of touches the player has made
-- return: true, if this collision was allowed, false if it was a mistake. If false is returned,
-- the ball is resetted and OnMistake is called.
function OnBallHitsPlayer(player, touches)
return touches <= 3
end
|