fix README, SYNC, DATENSCHUTZ
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Dynamic Branch Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// --- INTERNE STATE STRUKTUR ---
|
||||
type SimState struct {
|
||||
SessionID string
|
||||
Score int
|
||||
@@ -37,16 +36,10 @@ type SimState struct {
|
||||
Chunks []ChunkDef
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// HAUPTFUNKTION
|
||||
// ============================================================================
|
||||
|
||||
func simulateChunk(sessionID string, inputs []Input, totalTicks int, vals map[string]string) (bool, int, []ActiveObstacle, []ActivePlatform, PowerUpState, int, int, uint32) {
|
||||
|
||||
// 1. State laden
|
||||
state := loadSimState(sessionID, vals)
|
||||
|
||||
// 2. Bot-Check
|
||||
if isBotSpamming(inputs) {
|
||||
log.Printf("🤖 BOT-ALARM [%s]: Spammt Sprünge", sessionID)
|
||||
state.IsDead = true
|
||||
@@ -73,42 +66,32 @@ func simulateChunk(sessionID string, inputs []Input, totalTicks int, vals map[st
|
||||
state.Score++
|
||||
}
|
||||
|
||||
// 4. Anti-Cheat Heuristik
|
||||
if state.SuspicionScore > 15 {
|
||||
log.Printf("🤖 BOT-ALARM [%s]: Zu perfekte Sprünge (Heuristik)", sessionID)
|
||||
state.IsDead = true
|
||||
}
|
||||
|
||||
// 5. Speichern
|
||||
saveSimState(&state)
|
||||
return packResponse(&state)
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// LOGIK & PHYSIK FUNKTIONEN
|
||||
// ============================================================================
|
||||
|
||||
func updatePhysics(s *SimState, didJump, isCrouching bool, currentSpeed float64) {
|
||||
// 1. Powerup Logik (Jump Boots)
|
||||
|
||||
jumpPower := JumpPower
|
||||
if s.BootTicks > 0 {
|
||||
jumpPower = HighJumpPower
|
||||
s.BootTicks--
|
||||
}
|
||||
|
||||
// 2. Sind wir am Boden?
|
||||
isGrounded := checkGrounded(s)
|
||||
|
||||
// 3. Ducken / Fast Fall
|
||||
// (Variable 'currentHeight' entfernt, da sie hier nicht gebraucht wird)
|
||||
if isCrouching {
|
||||
// Wenn man in der Luft duckt, fällt man schneller ("Fast Fall")
|
||||
|
||||
if !isGrounded {
|
||||
s.VelY += 2.0
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Springen
|
||||
if didJump && isGrounded && !isCrouching {
|
||||
s.VelY = jumpPower
|
||||
isGrounded = false
|
||||
@@ -122,47 +105,30 @@ func updatePhysics(s *SimState, didJump, isCrouching bool, currentSpeed float64)
|
||||
|
||||
landed := false
|
||||
|
||||
// ============================================================
|
||||
// PLATTFORM KOLLISION (MIT VERTICAL SWEEP)
|
||||
// ============================================================
|
||||
if s.VelY > 0 {
|
||||
|
||||
if s.VelY > 0 { // Nur wenn wir fallen
|
||||
|
||||
// Wir nutzen hier die Standard-Höhe für die Füße.
|
||||
// Auch beim Ducken bleiben die Füße meist unten (oder ziehen hoch?),
|
||||
// aber für die Landung auf Plattformen ist die Standard-Box sicherer.
|
||||
playerFeetOld := oldY + PlayerHeight
|
||||
playerFeetNew := newY + PlayerHeight
|
||||
|
||||
// Player X ist fest bei 50, Breite 30
|
||||
pLeft := 50.0
|
||||
pRight := 50.0 + 30.0
|
||||
|
||||
for _, p := range s.Platforms {
|
||||
|
||||
// 1. Horizontal Check (Großzügig!)
|
||||
// Toleranz an den Rändern (-5 / +5), damit man nicht abrutscht
|
||||
if (pRight-5.0 > p.X) && (pLeft+5.0 < p.X+p.Width) {
|
||||
|
||||
// 2. Vertikaler Sweep (Durchsprung-Schutz)
|
||||
// Check: Füße waren vorher <= Plattform-Oberkante
|
||||
// UND Füße sind jetzt >= Plattform-Oberkante
|
||||
if playerFeetOld <= p.Y && playerFeetNew >= p.Y {
|
||||
|
||||
// Korrektur: Wir setzen den Spieler exakt AUF die Plattform
|
||||
newY = p.Y - PlayerHeight
|
||||
s.VelY = 0
|
||||
landed = true
|
||||
isGrounded = true
|
||||
break // Landung erfolgreich
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// BODEN KOLLISION
|
||||
// ============================================================
|
||||
if !landed {
|
||||
if newY >= PlayerYBase {
|
||||
newY = PlayerYBase
|
||||
@@ -171,7 +137,6 @@ func updatePhysics(s *SimState, didJump, isCrouching bool, currentSpeed float64)
|
||||
}
|
||||
}
|
||||
|
||||
// Neue Position setzen
|
||||
s.PosY = newY
|
||||
}
|
||||
|
||||
@@ -186,7 +151,7 @@ func checkCollisions(s *SimState, isCrouching bool, currentSpeed float64) {
|
||||
activeObs := []ActiveObstacle{}
|
||||
|
||||
for _, obs := range s.Obstacles {
|
||||
// Passed Check
|
||||
|
||||
paddingX := 10.0
|
||||
if obs.X+obs.Width-paddingX < 55.0 {
|
||||
activeObs = append(activeObs, obs)
|
||||
@@ -286,21 +251,19 @@ func handleSpawning(s *SimState, speed float64) {
|
||||
if s.Ticks >= s.NextSpawnTick {
|
||||
spawnX := GameWidth + 3200.0
|
||||
|
||||
// --- OPTION A: CUSTOM CHUNK (20% Chance) ---
|
||||
chunkCount := len(defaultConfig.Chunks)
|
||||
if chunkCount > 0 && s.RNG.NextFloat() > 0.8 {
|
||||
|
||||
idx := int(s.RNG.NextRange(0, float64(chunkCount)))
|
||||
chunk := defaultConfig.Chunks[idx]
|
||||
|
||||
// Objekte spawnen
|
||||
for _, p := range chunk.Platforms {
|
||||
s.Platforms = append(s.Platforms, ActivePlatform{
|
||||
X: spawnX + p.X, Y: p.Y, Width: p.Width, Height: p.Height,
|
||||
})
|
||||
}
|
||||
for _, o := range chunk.Obstacles {
|
||||
// Fehler behoben: Zugriff auf o.X, o.Y jetzt möglich dank neuem Types-Struct
|
||||
|
||||
s.Obstacles = append(s.Obstacles, ActiveObstacle{
|
||||
ID: o.ID, Type: o.Type, X: spawnX + o.X, Y: o.Y, Width: o.Width, Height: o.Height,
|
||||
})
|
||||
@@ -311,20 +274,14 @@ func handleSpawning(s *SimState, speed float64) {
|
||||
width = 2000
|
||||
}
|
||||
|
||||
// Fehler behoben: Mismatched Types (int vs float64)
|
||||
s.NextSpawnTick = s.Ticks + int(float64(width)/speed)
|
||||
|
||||
} else {
|
||||
// --- OPTION B: RANDOM GENERATION ---
|
||||
spawnRandomObstacle(s, speed, spawnX)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// HELPER
|
||||
// ============================================================================
|
||||
|
||||
func loadSimState(sid string, vals map[string]string) SimState {
|
||||
rngState, _ := strconv.ParseInt(vals["rng_state"], 10, 64)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user