Skip to content

Commit

Permalink
Merge pull request #224 from fleizean/spa
Browse files Browse the repository at this point in the history
Spa
  • Loading branch information
fyurtsev authored Apr 18, 2024
2 parents 2428c63 + bc0d563 commit 256077e
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 27 deletions.
14 changes: 7 additions & 7 deletions indianpong/indianpong/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
# See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = environ.get("SECRET_KEY", default="w^bxst+y6yv=d*5+7h)2s3)5vfz!b2jayit+#1epn(gr1-fotw")
SECRET_KEY = environ.get("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = environ.get("DEBUG", default=False)
DEBUG = environ.get("DEBUG", default=False) == 'True'

BASE_URL = environ.get("BASE_URL", default='https://localhost:8443')

Expand Down Expand Up @@ -121,9 +121,9 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.getenv('POSTGRES_DB', default='pong'),
'USER': os.getenv('POSTGRES_USER', default='indianpong'),
'PASSWORD': os.getenv('POSTGRES_PASSWORD', default='indianpong123'),
'NAME': os.getenv('POSTGRES_DB'),
'USER': os.getenv('POSTGRES_USER'),
'PASSWORD': os.getenv('POSTGRES_PASSWORD'),
'HOST': 'db',
'PORT': '5432',
}
Expand Down Expand Up @@ -197,8 +197,8 @@
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = environ.get("EMAIL_HOST_USER", default="[email protected]")
EMAIL_HOST_PASSWORD = environ.get("EMAIL_HOST_PASSWORD", default="hxog cqpq jltp xjhi")
EMAIL_HOST_USER = environ.get("EMAIL_HOST_USER")
EMAIL_HOST_PASSWORD = environ.get("EMAIL_HOST_PASSWORD")
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
EMAIL_USE_TLS = True
EMAIL_USE_SSL = False
Expand Down
1 change: 1 addition & 0 deletions indianpong/pong/consumer_rps.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ async def receive(self, text_data):
'player1_score': player1_score,
'player2_score': player2_score,
})
await self.exit_handler(game_id, game)


### Handlers ###
Expand Down
6 changes: 3 additions & 3 deletions indianpong/pong/management/commands/initdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class Command(BaseCommand):
def handle(self, *args, **options):
# Create superuser if not exists
superuser = environ.get("SUPER_USER", default="Bitlis")
supermail = environ.get("SUPER_MAIL", default="[email protected]")
superpass = environ.get("SUPER_PASS", default="9247")
superuser = environ.get("SUPER_USER")
supermail = environ.get("SUPER_MAIL")
superpass = environ.get("SUPER_PASS")
if not UserProfile.objects.filter(username=superuser).exists():
super_user = UserProfile.objects.create_superuser(superuser, supermail, superpass)
file = File(open('static/assets/profile/default_avatar.jpeg', "rb"))
Expand Down
6 changes: 3 additions & 3 deletions indianpong/pong/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def auth(request):
return redirect("dashboard")
auth_url = "https://api.intra.42.fr/oauth/authorize"
fields = {
"client_id": "u-s4t2ud-4b7a045a7cc7dd977eeafae807bd4947670f273cb30e1dd674f6bfa490ba6c45", # environ.get("FT_CLIENT_ID"),
"client_id": environ.get("FT_CLIENT_ID"),
"redirect_uri": f"{settings.BASE_URL}/auth_callback", # This should be parameterized
"scope": "public",
# "state": state_req, # This will generate a 50-character long random string
Expand All @@ -151,8 +151,8 @@ def auth_callback(request):
code = request.GET.get("code")
data = {
"grant_type": "authorization_code",
"client_id": "u-s4t2ud-4b7a045a7cc7dd977eeafae807bd4947670f273cb30e1dd674f6bfa490ba6c45", # environ.get("FT_CLIENT_ID"),
"client_secret": "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", # environ.get("FT_CLIENT_SECRET"),
"client_id": environ.get("FT_CLIENT_ID"),
"client_secret": environ.get("FT_CLIENT_SECRET"),
"code": code,
"redirect_uri": f"{settings.BASE_URL}/auth_callback",
}
Expand Down
4 changes: 0 additions & 4 deletions indianpong/static/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,12 @@ const langMessages = {
const chatsocket = new WebSocket("wss://" + window.location.host + "/ws/chat/" + roomName + "/")

chatsocket.onopen = function (e) {
console.log("socket opened")
}

chatsocket.onclose = function (e) {
console.error("socket closed unexpectedly")
}

chatsocket.onerror = function (e) {
console.error("socket error")
}

function messageMe(data){
Expand Down Expand Up @@ -256,7 +253,6 @@ document.addEventListener('click', function(e) {
}

inviteButton.onclick = function (e) {
//console.log("invite button clicked");
chatsocket.send(JSON.stringify({
"action": "invite.game",
}))
Expand Down
4 changes: 2 additions & 2 deletions indianpong/static/js/game/play-ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,8 @@ reactionDelaySlider.oninput = function() {
let value = (this.value-this.min)/(this.max-this.min)*100
} */
let reactionDelay = 1000/(ball.speed*2)//Math.round(reactionDelaySlider.value / ball.speed);
if (username === "Bitlis")
reactionDelay = 250000;
let lastBallPosition = { x: ball.x, y: ball.y };
let ballDirection = { x: 0, y: 0 };
let predictedY = paddle2.y;
Expand All @@ -551,7 +553,6 @@ setInterval(() => {
if (fastandFurious == "true" && aiFastandFuriousCount < 1 && isFrozenBallActive == false) {
// Top rakip yarı sahaya doğru gidiyorsa ve topun X koordinatı AI'nın ceza sahasında ise
if (ball.dx < 0 && ball.x > canvas.width / 2 && ball.x < canvas.width - paddle2.width && ball.speed > 5) {
//console.log("AI Fast and Furious yeteneğini kullandı ve değerleri şu şekilde: ", ball.speed);
ball.speed += 10;
startfastandFuriousSound();
aiFastandFuriousCount += 1;
Expand All @@ -561,7 +562,6 @@ setInterval(() => {

if (likeaCheater == "true" && aiLikeaCheaterCount < 1) {
if (score2 < score1 || score1 === MAX_SCORE - 1 || score2 + 1 === MAX_SCORE) {
// console.log("AI Like a Cheater yeteneğini kullandı ve değerleri şu şekilde: ", score1, score2);
likeaCheaterAbility(true);
aiLikeaCheaterCount += 1;
}
Expand Down
1 change: 0 additions & 1 deletion indianpong/static/js/game/sockPong.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ matchsocket.onerror = function (e) {

matchsocket.onmessage = function (e) {
const data = JSON.parse(e.data);
//console.log(data);
if (window.location.pathname.includes('/remote-game')) {
switch (data.type) {
case 'inlobby':
Expand Down
8 changes: 4 additions & 4 deletions indianpong/static/js/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ function showToast(content, status, iconClass) {
document.getElementById('itemNameInput').value = itemName;
var propertyContent = document.getElementById('propertyContent');
if (itemName === "My Playground" || itemName === "My Beautiful Paddle") {
itemWhatIs = itemWhatIs || '#000000';
propertyContent.innerHTML = `
itemWhatIs = (itemWhatIs !== "none") ? itemWhatIs : '#000000';
propertyContent.innerHTML = `
<label for="color">Choose Color:</label>
<input type="color" id="color" name="whatis" value="${itemWhatIs}">
<input type="color" style="margin-left:7px;" id="color" name="whatis" value="${itemWhatIs}">
`;
} else {
itemWhatIs = itemWhatIs || 'IndianAI';
propertyContent.innerHTML = `
<label for="propertyName">AI Name:</label>
<input type="text" id="propertyName" name="whatis" value="${itemWhatIs}">
<input type="text" style="margin-left:7px;" id="propertyName" name="whatis" value="${itemWhatIs}">
`;
}

Expand Down
1 change: 0 additions & 1 deletion indianpong/static/js/profile-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export function editProfile(username) {
if (message)
showToast(message, 'text-bg-success', 'bi bi-check-circle-fill');
else {

if (lang === 'tr') {
showToast('Bir hata oluştu.', 'text-bg-danger', 'bi bi-x-circle-fill');
} else if (lang === 'hi') {
Expand Down
4 changes: 2 additions & 2 deletions indianpong/static/js/sockRps.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ websocket.onmessage = function (e) {
godthingsAbilities = true;
else if (my.username === player2.username && player2_choice === "GODOFTHINGS")
godthingsAbilities = true;

scoreUpdate(player1_score, player2_score);

console.log(player1_score + ' ' + player2_score);
displayResults([player1_choice, player2_choice]);
displayWinner(result);
break;
Expand Down

0 comments on commit 256077e

Please sign in to comment.