[Gamesnws-commits] r32 - in pkg: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 13 17:19:34 CEST 2009


Author: grafab
Date: 2009-08-13 17:19:34 +0200 (Thu, 13 Aug 2009)
New Revision: 32

Modified:
   pkg/DESCRIPTION
   pkg/R/adminUno.R
   pkg/R/playUno.R
   pkg/man/computerPlayerUNO.Rd
   pkg/man/playUno.Rd
   pkg/man/startUnoGame.Rd
Log:
doc-files overworked

Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2009-08-13 09:34:35 UTC (rev 31)
+++ pkg/DESCRIPTION	2009-08-13 15:19:34 UTC (rev 32)
@@ -6,6 +6,6 @@
 Author: Markus Schmidberger, Fabian Grandke
 Maintainer: Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>
 Depends: nws
-Description: A package with different games (e.g. uno, poker, ...) using a NWS Server. You can play the games with your friends in the whole world. Just install a NWS Server, send the login data to your friends and start the game. 
+Description: This is a package with different card games (e.g. uno, poker, ...) and using a NWS Server as card table. You can play the games with your friends in the whole world. Just install a NWS Server at one machine, send the login data to your friends and start the game. 
 License: GPL
 LazyLoad: yes
\ No newline at end of file

Modified: pkg/R/adminUno.R
===================================================================
--- pkg/R/adminUno.R	2009-08-13 09:34:35 UTC (rev 31)
+++ pkg/R/adminUno.R	2009-08-13 15:19:34 UTC (rev 32)
@@ -1,7 +1,7 @@
 #####################################
 # Function to create Uno Game in NWS
 #####################################
-createUnoGame <- function(wsName, ...)
+.createUnoGame <- function(wsName, ...)
 {
 	require(nws)
 	nwss<-nwsServer(...)
@@ -61,13 +61,14 @@
 	nwsStore(ws, 'players_logedin', 'master')
 
 	#Some output
-	cat("Send the NWS-name and the server address to your other players and\n")
-	cat("start the game with the command 'startUnoGame(ws)'\n\n")
+	#cat("Send the NWS-name and the server address to your other players and\n")
+	#cat("start the game with the command 'startUnoGame(ws)'\n\n")
 
 	return(ws)
  }
  else{    #if workspacename allready exists
- cat("Workspacename allready exists, please try another name\n")
+ #cat("Workspacename allready exists, please try another name\n")
+ return("notaws")
  }
 }
 
@@ -76,11 +77,12 @@
 # especially to get commands from master-user
 # and to wait for other players
 ############################################################
-startUnoGame <- function(ws, cardsStart=7, 
+startUnoGame <- function(wsName, cardsStart=7, 
 		minPlayers=2, maxPlayers=10, 
-		log=0, logfile=NULL, debug=FALSE)
+		log=0, logfile=NULL, debug=FALSE,...)
 {	
 	require(nws)
+	ws<-.createUnoGame(wsName, ...)
   wsclass<-class(ws)
   if(wsclass[1]=="netWorkSpace"){
 	readCommand <- ""
@@ -121,7 +123,9 @@
 	nwsClose(ws)
 	cat("GAME OVER \n")
 	}else{
-    cat("ws is no valid networkspace, please create one")
+    cat("wsName is no valid networkspacename, please try another one")
+    	nwsDeleteWs(ws at server, ws at wsName)
+      nwsClose(ws)
   }
 }
 
@@ -206,7 +210,7 @@
 	#Operation during running game
 	cat("\tGame is running:\n")
 	if(log!=0){
-		winner <- watchUnoGame(ws, logfile=logfile)
+		winner <- .watchUnoGame(ws, logfile=logfile)
 	} else {
 		winner <- .txtProgressBarNWS(ws, 'winner') 	
 	}
@@ -224,7 +228,7 @@
 #               3 -> 2, handcards
 #               4 -> 3, date, time...
 ##########################################
-watchUnoGame <- function(ws, ..., logfile=NULL)
+.watchUnoGame <- function(ws, ..., logfile=NULL)
 {	
 	require(nws)
 	

Modified: pkg/R/playUno.R
===================================================================
--- pkg/R/playUno.R	2009-08-13 09:34:35 UTC (rev 31)
+++ pkg/R/playUno.R	2009-08-13 15:19:34 UTC (rev 32)
@@ -1,6 +1,6 @@
 ###########################################################
 # Main Function to play UNO for user
-######################################################
+###########################################################
 playUno <- function(name, 
 		user=Sys.info()["user"], 
 		computerPlayer=FALSE, computerPlayerFunction=computerPlayerUNO, 
@@ -42,17 +42,28 @@
     for(p in players){
       string<-c(string,p)
     }
-		pb <- txtProgressBar(min=0, max=10, style=1, width=10)
-		i <- 1
+    playerInActionOld <- nwsFindTry(ws, 'player_in_action')
+    pb <- txtProgressBar(min=0, max=10, style=1, width=1,char=paste("Wait for ",playerInActionOld," to act"))
+    i <- 1
     run <- 0
 		while( nwsFindTry(ws, 'player_in_action')!=user && is.null(nwsFindTry(ws, 'winner')) ){
-			setTxtProgressBar(pb, i)
-			if(run==0)
+			playerInAction <- nwsFindTry(ws, 'player_in_action')
+      if(playerInActionOld!=playerInAction){# if player changed, 
+                                                                                #new progressbar with player name
+        close(pb)
+        playerInActionOld<-playerInAction
+        pb <- txtProgressBar(min=0, max=10, style=1, width=1,char=paste("Wait for ",playerInAction," to act"))
+        i <- 1
+        run <- 0
+      }
+      setTxtProgressBar(pb, i)
+		  if(run==0)
 				i <- i+1
-			else i <- i-1
+		  else 
+        i <- i-1
 			if(i==10) run<-1
 			if(i==1) run<-0
-			Sys.sleep(0.1) #to reduce requests to NWS
+		Sys.sleep(0.1) #to reduce requests to NWS
 		}
 		close(pb)
 		playerInAction <- nwsFindTry(ws, 'player_in_action')

Modified: pkg/man/computerPlayerUNO.Rd
===================================================================
--- pkg/man/computerPlayerUNO.Rd	2009-08-13 09:34:35 UTC (rev 31)
+++ pkg/man/computerPlayerUNO.Rd	2009-08-13 15:19:34 UTC (rev 32)
@@ -9,19 +9,23 @@
                     card_played)
 }
 \arguments{
-  \item{ws}{name of workspace, that is used in the whole program}
+  \item{ws}{workspace object, that is used in the whole program}
   \item{hand}{A vector of cards, which the player holds in his hand.}
   \item{card_played}{A string, which indicates the latest played card.}
 }
 \details{
-	This function will be called in the playUno() Function.
-	Please feel free to write your own computer player!
+	This function will be called in the playUno() function.
+	Please feel free to write your own computer player and assign the new function to playUno() with the parameter computerPlayerFunction='yourComputerPlayer'!
+  The computerplayer does not have to say "UNO". The value can just be changed.
 }
 \value{
 A list of two named strings, 
 \item{selected_card}{A string for the card, the player selected from his hand and has to be removed from his hand.}
-\item{played_card}{A string for the card, the player plays. Especially for color-selection cards (rybg), a color-rybg string has to be returned.}
+\item{played_card}{A string for the card, the player plays. Especially for color-selection cards (rybg), a color-rybg string has to be returned. If no card is played "NO" is returned. Usual cards are in format "color-value".}
 }
+\references{
+\url{http://gamesnws.r-forge.r-project.org/}
+}
 \author{
 Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>, 
 Fabian Grandke

Modified: pkg/man/playUno.Rd
===================================================================
--- pkg/man/playUno.Rd	2009-08-13 09:34:35 UTC (rev 31)
+++ pkg/man/playUno.Rd	2009-08-13 15:19:34 UTC (rev 32)
@@ -1,8 +1,8 @@
 \name{playUno}
 \Rdversion{1.1}
 \alias{playUno}
-\title{The function, that has to be called by each UNO-player}
-\description{The player calls it and inputs all necessary values. 
+\title{The players play-function}
+\description{The player calls the function and inputs all necessary values. 
 The function rules the whole course of the UNO-game.}
 \usage{
 playUno(  name, 
@@ -13,29 +13,36 @@
 \arguments{
   \item{name}{Name of the workspace}
   \item{user}{playername}
-  \item{computerPlayer}{is the player manual or automatical controlled}
+  \item{computerPlayer}{a logical, if TRUE the player is controlled by computerplayer, else, human controlled}
   \item{computerPlayerFunction}{which computerplayer is used}
-  \item{\dots}{}
+  \item{...}{Usual parameters to initialize a netWorkSpace(). See \url{http://nws-r.sourceforge.net/doc/nwsR-1.5.0.pdf} (Page 25) for further information}
 }
 \details{
-This function rules everything, a player needs. It asks for decisions and shows information.
-Commands:
-say-uno: before playing the second-last card, you have to say uno
+This function rules the whole game course. It asks the player for decisions and shows the relevant information.
+The funtion shows the last played card, what cards are on your hand, which players are involved and how many card each player has.
+To control the game options, there are specific commands the player has to use:
+
+say-uno: before playing the second-last card, player has to announce "UNO"
 get-info: shows some game relevant information
-color*-number**: plays card
+color*-value**: the card that should be played(one of the players handcards)
+NO: if the player isn't able or don't wants to play 
+color*: after playing a rybg-card the player has to name a color, that has to be played next
 
 
-*color=(red,yellow,blue,green,rybg)
-**number=(0:9,2+,4+)
+*one of the "colors"(red,yellow,blue,green,rybg)
+**one of the "card values"=(0:9,2+,4+,BREAK,BACK)
 
 }
+\references{
+\url{http://gamesnws.r-forge.r-project.org/}
+}
 \author{
 Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>, 
 Fabian Grandke
 }
 \examples{
 \dontrun{
-	playUno("test",user="tom",serverHost="138.245.80.17")
+	playUno("test",user="tom",serverHost="localhost")
 }
 \dontrun{
   playUno("test2",user="paul",computerPlayer=TRUE)

Modified: pkg/man/startUnoGame.Rd
===================================================================
--- pkg/man/startUnoGame.Rd	2009-08-13 09:34:35 UTC (rev 31)
+++ pkg/man/startUnoGame.Rd	2009-08-13 15:19:34 UTC (rev 32)
@@ -1,43 +1,46 @@
 \name{startUnoGame}
 \Rdversion{1.1}
 \alias{startUnoGame}
-\title{Starts the UNO-Game that is in the given workspace}
-\description{After a UNO-Game is created in a workspace, it gets started with this function.}
+\title{Creates workspace and starts the UNO-Game - For Admin}
+\description{The Admin creates a workspace, starts an UNO-Game and dicides what game-conditions apply.}
 \usage{
-startUnoGame( ws, 
+startUnoGame( wsName, 
               cardsStart = 7, 
               minPlayers = 2, 
               maxPlayers = 10, 
               log = 0, 
               logfile = NULL, 
-              debug = FALSE)
+              debug = FALSE,
+              ...)
 }
 \arguments{
-  \item{ws}{workspace with a created UNO-Game in it}
+  \item{wsName}{workspacename}
   \item{cardsStart}{the number of cards, each player gets at the beginning}
   \item{minPlayers}{the number of players, that are necessary to start a game}
   \item{maxPlayers}{the number of players, that maximal can join a game}
-  \item{log}{number of log mode}
-  \item{logfile}{the directory, where the log should be saved to(not yet implemented)}
-  \item{debug}{logical variable if debug mode is enabled}
+  \item{log}{number of log mode : 0 = no logging, !0=logging }
+  \item{logfile}{the file, where the log should be saved to(not yet implemented)}
+  \item{debug}{a logical, if TRUE, there are several debuginformation shown during the game}
+  \item{...}{Usual parameters to initialize a netWorkSpace(). See \url{http://nws-r.sourceforge.net/doc/nwsR-1.5.0.pdf} (Page 25) for further information}
 }
 \details{
 After starting the game, with this function, the players could log in with playUno().
-When you started the game, you can decide the play mode.
-
+This function only creates and starts the game. It does not play.
 }
-
+\references{
+\url{http://gamesnws.r-forge.r-project.org/}
+}
 \author{
 Markus Schmidberger <schmidb at ibe.med.uni-muenchen.de>, 
 Fabian Grandke
 }
 \examples{
 \dontrun{
-  ws<-createUnoGame("test","138.245.80.17")
+  ws<-createUnoGame("test","localhost")
   startUnoGame(ws,log=1)
 }
 \dontrun{
-  ws<-createUnoGame("test","138.245.80.17")
+  ws<-createUnoGame("test","localhost")
   startUnoGame(ws, cardsStart=13, minPlayers=4)
 }
 }
\ No newline at end of file



More information about the Gamesnws-commits mailing list