Skip to content
This repository was archived by the owner on Jun 11, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
731b26c
World Battery Start
Shnacko Apr 18, 2023
ad7a073
Merge pull request #1 from allegheny-college-cmpsc-100-spr-2023/Tyler…
jmsjones12 Apr 19, 2023
858b559
Changes
jmsjones12 Apr 19, 2023
954ad83
Merge branch 'main' of github.com:allegheny-college-cmpsc-100-spr-202…
jmsjones12 Apr 19, 2023
8219674
World Battery Work
jmsjones12 Apr 19, 2023
026ba47
Merge pull request #2 from allegheny-college-cmpsc-100-spr-2023/World…
jmsjones12 Apr 19, 2023
78a2f68
Working add power
Shnacko Apr 19, 2023
769dad7
Merge branch 'main' into Tyler-World-Battery
Shnacko Apr 19, 2023
46a53f1
Merge pull request #3 from allegheny-college-cmpsc-100-spr-2023/Tyler…
Shnacko Apr 19, 2023
c561c12
Prototype
Gogurk Apr 20, 2023
88e6c66
Functional
Gogurk Apr 20, 2023
20d121f
Merge pull request #5 from allegheny-college-cmpsc-100-spr-2023/NameL…
Gogurk Apr 21, 2023
eaf7480
Functional
Gogurk Apr 21, 2023
8ef05de
Merge pull request #6 from allegheny-college-cmpsc-100-spr-2023/NameL…
Gogurk Apr 21, 2023
c315664
Splitting power
Shnacko Apr 21, 2023
b90515f
power pulls from renewable first
Shnacko Apr 21, 2023
eec3429
Update name.py
Gogurk Apr 21, 2023
cf9e928
Battery updates
Shnacko Apr 24, 2023
9d361ee
battery updates
Shnacko Apr 24, 2023
2fe1a21
os.path.dirname addition
Shnacko Apr 25, 2023
1bb4a5b
Merge pull request #7 from allegheny-college-cmpsc-100-spr-2023/Tyler…
Shnacko Apr 25, 2023
708e02f
Just testing some things
Shnacko Apr 27, 2023
c52f1cd
prototype namelog
Shnacko Apr 28, 2023
8363f23
Finished Copy
Gogurk Apr 28, 2023
2a8f622
Merge pull request #9 from allegheny-college-cmpsc-100-spr-2023/NameL…
Shnacko Apr 28, 2023
9ee5dee
Finished
Gogurk Apr 28, 2023
6a99688
Merge branch 'main' of github.com:allegheny-college-cmpsc-100-spr-202…
Gogurk Apr 28, 2023
d815115
Test 2
Gogurk Apr 28, 2023
d7c4141
Merge branch 'NameLogger'
Gogurk Apr 28, 2023
57a6e8d
FINAL CODE
Shnacko May 7, 2023
09b056d
Merge pull request #12 from allegheny-college-cmpsc-100-spr-2023/FINA…
Shnacko May 7, 2023
9a59056
Merge branch 'term-world:main' into main
dluman May 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libs/resources/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .fossil import Oil, Coal, NaturalGas
from .synthetic import Nuclear
from .renewable import Wind, Solar, Water
from .powergrid import PowerGrid
from .namelog import UserLog
1 change: 1 addition & 0 deletions libs/resources/resources/log.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"user": "Shnacko", "time": 1682952779.590532, "wind": 4533.017306686408, "solar": 0, "coal": 0, "oil": 0, "nuclear": 0, "natural_gas": 0}]
31 changes: 31 additions & 0 deletions libs/resources/resources/namelog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json
import os
import getpass
from datetime import datetime
import time

class UserLog:

def log_user(wind = 0, solar = 0, coal = 0, oil = 0, nuclear = 0, natural_gas = 0):
path = os.path.dirname(__file__)
with open(f"{path}/log.json", "r") as fh:
log = json.load(fh)

name = getpass.getuser()
now = datetime.now().timestamp()

entry = {
"user": name,
"time": now,
"wind": wind,
"solar": solar,
"coal": coal,
"oil": oil,
"nuclear": nuclear,
"natural_gas": natural_gas
}

log.append(entry)

with open(f"{path}/log.json", "w") as fh:
json.dump(log, fh)
38 changes: 38 additions & 0 deletions libs/resources/resources/powergrid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import json
import sys
import os

class PowerGrid:

#Turn this perameter into a dictionary
def add_power(wind = 0, solar = 0, coal = 0, oil = 0, nuclear = 0, natural_gass = 0):
# sorts power based on its source and adds it to the power grid
path = os.path.dirname(__file__)
renewable_energy = wind + solar
exhaustable_energy = coal + oil + nuclear + natural_gass
with open(f"{path}/worldbattery.json", "r") as fh:
world_battery = json.load(fh)
world_battery["renewable_energy"] += renewable_energy
world_battery["exhaustable_energy"] += exhaustable_energy
with open(f"{path}/worldbattery.json", "w") as add_battery:
json.dump(world_battery, add_battery)

# Takes a perameter that is the ammount of power it takes to run the object
def use_power(power):
path = os.path.dirname(__file__)
with open(f"{path}/worldbattery.json", "r") as fh:
world_battery = json.load(fh)

if world_battery["renewable_energy"] >= power:
world_battery["renewable_energy"] -= power
print("You Can Feel Good Knowing This Was Powered By Renewable Energy! ")
elif world_battery["exhaustable_energy"] >= power:
world_battery["exhaustable_energy"] -= power
print("Hope you are happy. You powered it, but now the earth is a little more polluted.")
print("🏭")
elif world_battery["renewable_energy"] < power and world_battery["exhaustable_energy"] < power:
print("There Is Not Enough Power In The World. Generate Some More And Try Again. ")
sys.exit()

with open(f"{path}/worldbattery.json", "w") as add_battery:
json.dump(world_battery, add_battery)
1 change: 1 addition & 0 deletions libs/resources/resources/worldbattery.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"renewable_energy": 54332.16092373188, "exhaustable_energy": 52808}