Community   Maps   Forum   Mail   Ladders   Clans   Recent Games
Sign In | Sign Up
<< Back to Programming Forum   

Posts 1 - 6 of 6   
Get Win% in column: 10/2/2013 20:43:56

Level 60
I still can't manage to do this, can anybody help me? I have It grabbing Wins, Losses and Total games...I can't figure out how to get Win % in there.

Here are the important parts of my code:

As you can see I comment the parts of the code that are not original. All of it works except the parts I added today in

I get this error on the website:

File "/base/data/home/apps/s~wg-rotating-1v1/1.370641115765141202/templates/renderlot.html", line 31, in top-level template code
<td {%if not in container.lot.playersParticipating %} style="background-color: #A4A4A4" {%endif%}>{{ container.lot.playerWinPercentage.get(, 0) }}</td>
UndefinedError: 'None' has no attribute 'get'
Get Win% in column: 10/3/2013 01:32:20

Level 57

WarLight Creator
If you have wins and total games, can't you just divide them to get the win%?

UndefinedError: 'None' has no attribute 'get'

This is saying that playerWinPercentage is None (i.e. null). You should figure out why that thing isn't set to figure out why this error is happening.
Get Win% in column: 10/3/2013 15:04:01

Level 60
Well, I was trying to do that with the part at the bottom of the image I posted, but something isn't working. I did:

winpercentage = finishedGamesGroupedByTotalGames/finishedGamesGroupedByWinner*100

Since the container is an integer value I multiplied by 100.

I am missing something though, I just can't figure out what.
Get Win% in column: 10/4/2013 14:40:32

Level 65
1. finishedGamesGroupedByTotalGames/finishedGamesGroupedByWinner

assuming finishedGamesGroupedByTotalGames - wins
and finishedGamesGroupedByWinner - totalgames
it should be finishedGamesGroupedByWinner/finishedGamesGroupedByTotalGames

2 but the problem is, that all those variables are probably integers, so

wins/totalgames = 0 (always, except wins=totalgames) so wins/totalgames * 100 = 0

try: float(wins)/totalgames * 100

Edited 10/4/2013 14:42:25
Get Win% in column: 10/15/2013 22:49:42

Level 60
Whoops, I put those in wrong order, good catch.

I tried:

winpercentage = float(finishedGamesGroupedByWinner)/finishedGamesGroupedByTotalGames*100

And both times it gave me this error:

"float() argument must be a string or a number"

I don't understand because if I am seeing things right, then finishedGamesGroupedByWinner should be an integer.
Get Win% in column: 10/15/2013 23:46:10

Level 57

WarLight Creator
finishedGamesGroupedByWinner sounds like it's a dictionary or list or something. You should check its type.

Python can't divide a list of numbers, it can only divide numbers. Example:

>>> 3.0 / 4.0
>>> [2.0, 3.0, 4.0] / [5.0, 6.0, 7.0]

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    [2.0, 3.0, 4.0] / [5.0, 6.0, 7.0]
TypeError: unsupported operand type(s) for /: 'list' and 'list'

It sounds like you need to loop through the players and divide each one.
Posts 1 - 6 of 6   

Contact | About WarLight | Play Risk Online | Multiplayer Strategy Game | Challenge Friends, Win Money | Skill Game | Terms of Service