Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
104 changes: 104 additions & 0 deletions .github/workflows/vice-apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: VICE VI Mobile APK

# Gera o APK Android de VICE VI Mobile (GTA VI Mobile — Estado de Leonida)
# e empacota o jogo completo para download direto nos artefatos do GitHub Actions.

on:
push:
branches: [ "main", "arena/2261e308-nextvr-android" ]
pull_request:
paths:
- 'vice-game/**'
- 'tests/vice-game.test.mjs'
- '.github/workflows/vice-apk.yml'
workflow_dispatch:

permissions:
contents: write
checks: write

jobs:
build:
name: Build VICE VI Mobile APK
runs-on: ubuntu-latest
timeout-minutes: 40

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Set up JDK 21
uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '21'

- name: Set up Node
uses: actions/setup-node@v7
with:
node-version: '22'
cache: npm

- name: Install test dependencies
run: npm ci

- name: Run VICE VI Mobile test suite
run: node --test tests/vice-game.test.mjs

- name: Set up Gradle cache
uses: gradle/actions/setup-gradle@v6

- name: Build VICE VI Mobile APK
run: ./gradlew -p vice-game/android assembleRelease --no-daemon --stacktrace

- name: Verify APK contents
run: |
set -e
APK=$(find vice-game/android/app/build/outputs/apk -name '*.apk' -print -quit)
test -n "$APK"
echo "APK gerado: $APK ($(stat -c %s "$APK") bytes)"
unzip -Z1 "$APK" | grep -q '^assets/game/index\.html$'
unzip -Z1 "$APK" | grep -q '^assets/game/src/main\.js$'
unzip -Z1 "$APK" | grep -q '^assets/game/vendor/three\.module\.min\.js$'
unzip -Z1 "$APK" | grep -q '^assets/game/assets/brand/standing_man\.glb$'
unzip -Z1 "$APK" | grep -q '^assets/game/assets/brand/harlows_chevrolet_corvette_stingray_nfs_unbound\.glb$'

- name: Build offline bundle & package zip
run: |
set -e
node vice-game/tools/build-bundle.mjs
cd vice-game
zip -r ../vice6-mobile.zip index.html upload-glb.html styles src assets vendor serve.mjs README.md app.bundle.js -x '*.DS_Store'
cd ..
ls -lh vice6-mobile.zip

- name: Publish release with direct APK & ZIP download links
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'arena/2261e308-nextvr-android')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
APK=$(find "$GITHUB_WORKSPACE/vice-game/android/app/build/outputs/apk" -name '*.apk' -print -quit)
cp "$APK" "$GITHUB_WORKSPACE/vice6-mobile.apk"
TAG="vice6-mobile-v0.2.0"
NOTES="VICE VI Mobile (GTA 6 Mobile) v0.2.0 com os 8 modelos 3D .glb integrados (Corvette Stingray, Fiesta, Pontiac GTO, Cruze Police, Moto 004, Motorhome Triple E Commander, Standing Man + Citizen NPC Pack). Commit ${GITHUB_SHA}."
if ! gh release view "$TAG" > /dev/null 2>&1; then
gh release create "$TAG" --title "VICE VI Mobile (GTA 6 Mobile) v0.2.0 — Modelos 3D .GLB" \
--notes "$NOTES" --target "$GITHUB_SHA" --prerelease
else
gh release edit "$TAG" --title "VICE VI Mobile (GTA 6 Mobile) v0.2.0 — Modelos 3D .GLB" \
--notes "$NOTES" --target "$GITHUB_SHA" --prerelease
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/tags/$TAG" \
-f sha="$GITHUB_SHA" -F force=true > /dev/null
fi
gh release upload "$TAG" "$GITHUB_WORKSPACE/vice6-mobile.apk" "$GITHUB_WORKSPACE/vice6-mobile.zip" --clobber

- name: Upload APK and ZIP artifacts
uses: actions/upload-artifact@v7
with:
name: vice6-mobile-apk
path: |
vice-game/android/app/build/outputs/apk/release/*.apk
vice6-mobile.zip
if-no-files-found: error
retention-days: 30
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ xfc-game/android/.gradle/
xfc-game.zip
xfc-game/app.bundle.js
xfc-game/assets/crests/nations/.svg-source.json

# VICE VI Mobile: artefatos locais de build Android e bundle offline
vice-game/android/build/
vice-game/android/app/build/
vice-game/android/.gradle/
vice6-mobile.zip
vice-game/app.bundle.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "module",
"scripts": {
"build:ui": "node web/build.mjs",
"test": "node --test tests/*.test.mjs"
"test": "node --test --test-concurrency=2 tests/*.test.mjs"
},
"devDependencies": {
"@fontsource/inter": "5.2.8",
Expand Down
163 changes: 163 additions & 0 deletions tests/vice-game.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFile, stat } from 'node:fs/promises';

import {
AVENUES_X,
STREETS_Z,
DISTRICTS,
POINTS_OF_INTEREST,
districtAt,
isWaterAt,
isRoadAt,
isOnBridge,
generateCityLayout
} from '../vice-game/src/data/city.js';
import { VEHICLE_MODELS, RADIO_STATIONS, getVehicleModel } from '../vice-game/src/data/vehicles.js';
import { CHARACTERS, WEAPONS, MISSIONS, nextAvailableMission } from '../vice-game/src/data/missions.js';
import { defaultProfile, loadProfile, saveProfile, STORAGE_KEY } from '../vice-game/src/state.js';
import { startViceServer } from '../vice-game/serve.mjs';

test('mapa de Vice Leonida: bairros, pontes sobre o canal, praia, oceano e prédios sem invadir avenidas', () => {
assert.ok(DISTRICTS.length >= 6);
assert.equal(districtAt(300, 0).id, 'ocean-drive');
assert.equal(districtAt(390, 0).id, 'vice-beach-sand');
assert.equal(districtAt(510, 0).id, 'atlantic-ocean');
assert.equal(districtAt(-300, -100).id, 'downtown-leonida');

// Canal de Biscayne: água fora das pontes, seco sobre as pontes (Z = -140, 0, 140)
assert.equal(isOnBridge(-150, 0), true);
assert.equal(isWaterAt(-150, 0), false);
assert.equal(isWaterAt(-150, 70), true);
assert.equal(isRoadAt(300, 20), true);

const layout = generateCityLayout();
assert.ok(layout.buildings.length >= 35, 'cidade tem dezenas de prédios Art Déco, Midtown e arranha-céus');
assert.ok(layout.palms.length >= 60, 'orla e avenidas têm palmeiras tropicais');
assert.ok(POINTS_OF_INTEREST.some(p => p.kind === 'garage'), 'possui oficina Neon Customs');
assert.ok(POINTS_OF_INTEREST.some(p => p.kind === 'bank'), 'possui Banco Nacional de Leonida');

// Nenhum prédio pode bloquear o centro das avenidas principais
for (const b of layout.buildings) {
for (const ax of AVENUES_X) {
const minX = b.x - b.w * 0.5;
const maxX = b.x + b.w * 0.5;
assert.ok(!(ax > minX && ax < maxX), `prédio ${b.id} não invade avenida X=${ax}`);
}
for (const sz of STREETS_Z) {
const minZ = b.z - b.d * 0.5;
const maxZ = b.z + b.d * 0.5;
assert.ok(!(sz > minZ && sz < maxZ), `prédio ${b.id} não invade rua Z=${sz}`);
}
}
});

test('catálogo de protagonistas (Lucia & Jason), veículos, estações FM e campanha de missões', () => {
assert.deepEqual(CHARACTERS.map(c => c.id), ['lucia', 'jason']);
assert.ok(VEHICLE_MODELS.length >= 7);
assert.ok(VEHICLE_MODELS.some(v => v.isBike), 'inclui moto esportiva');
assert.ok(VEHICLE_MODELS.some(v => v.isPolice), 'inclui viatura policial VCPD');
assert.equal(getVehicleModel('cheetah-vice').category, 'super');

assert.ok(RADIO_STATIONS.length >= 5);
assert.ok(WEAPONS.length >= 5);
assert.ok(MISSIONS.length >= 4);

const first = nextAvailableMission([]);
assert.equal(first.id, 'welcome-vice');
const second = nextAvailableMission(['welcome-vice']);
assert.equal(second.id, 'neon-sprint');
});

test('persistência de perfil em localStorage (dinheiro, protagonista, armas e missões)', () => {
const mem = new Map();
const fakeStorage = {
getItem: k => (mem.has(k) ? mem.get(k) : null),
setItem: (k, v) => mem.set(k, String(v))
};

const p = defaultProfile();
assert.equal(p.characterId, 'lucia');
p.characterId = 'jason';
p.money = 19500;
p.completedMissions.push('welcome-vice');
assert.equal(saveProfile(p, fakeStorage), true);
assert.ok(mem.has(STORAGE_KEY));

const loaded = loadProfile(fakeStorage);
assert.equal(loaded.characterId, 'jason');
assert.equal(loaded.money, 19500);
assert.deepEqual(loaded.completedMissions, ['welcome-vice']);
assert.ok(loaded.ownedWeapons.includes('fist'));
});

test('servidor HTTP de VICE VI Mobile serve index.html, módulos ES e three.js local', async () => {
const { server, url } = await startViceServer();
try {
const htmlRes = await fetch(`${url}/`);
assert.equal(htmlRes.status, 200);
const html = await htmlRes.text();
assert.match(html, /VICE VI Mobile/);
assert.match(html, /src\/main\.js/);

const jsRes = await fetch(`${url}/src/main.js`);
assert.equal(jsRes.status, 200);
assert.match(jsRes.headers.get('content-type') || '', /javascript/);

const threeRes = await fetch(`${url}/vendor/three.module.min.js`);
assert.equal(threeRes.status, 200);

const studioRes = await fetch(`${url}/upload-glb.html`);
assert.equal(studioRes.status, 200);
assert.match(await studioRes.text(), /ENVIAR \.GLB/);

const listRes = await fetch(`${url}/api/models`);
assert.equal(listRes.status, 200);
const listJson = await listRes.json();
assert.equal(listJson.ok, true);
assert.ok(Array.isArray(listJson.models));
} finally {
server.close();
}
});

test('projeto Android isolado (APK) e workflow de CI existem sem tocar no settings.gradle raiz', async () => {
const rootSettings = await readFile('settings.gradle', 'utf8');
assert.ok(!rootSettings.includes('vice-game'), 'build raiz do NextVR permanece intocado');

const appGradle = await readFile('vice-game/android/app/build.gradle', 'utf8');
assert.match(appGradle, /applicationId\s+"com\.nextvr\.vice6"/);
assert.match(appGradle, /include 'vendor\/\*\*'/);

const activity = await readFile('vice-game/android/app/src/main/java/com/nextvr/vice6/MainActivity.java', 'utf8');
assert.match(activity, /https:\/\/vice6\.local\//);

const workflow = await readFile('.github/workflows/vice-apk.yml', 'utf8');
assert.match(workflow, /\.\/gradlew -p vice-game\/android assembleRelease/);

const threeStat = await stat('vice-game/vendor/three.module.min.js');
assert.ok(threeStat.size > 500_000, 'three.js local está presente para rodar 100% offline no APK');
});

test('todos os 8 modelos .glb enviados existem, têm assinatura glTF válida e estão mapeados nos veículos/personagens', async () => {
const expectedGlbs = [
'2011_chevrolet_cruze_police.glb',
'citizen_npc_pack_1_character_lowpoly_mobile.glb',
'fiesta_2012.glb',
'harlows_chevrolet_corvette_stingray_nfs_unbound.glb',
'moto_004.glb',
'pontiac_gto_police_2005.glb',
'standing_man.glb',
'triple_e_commander.glb'
];

for (const file of expectedGlbs) {
const buf = await readFile(`vice-game/assets/brand/${file}`);
assert.equal(buf.subarray(0, 4).toString('ascii'), 'glTF', `${file} é um binário glTF válido`);
assert.ok(buf.length > 50_000, `${file} tem geometria completa`);
}

for (const v of VEHICLE_MODELS) {
assert.ok(v.glbUrl && v.glbUrl.startsWith('assets/brand/'), `veículo ${v.id} aponta para um modelo .glb real`);
}
});
37 changes: 37 additions & 0 deletions vice-game/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# VICE VI Mobile — Estado de Leonida (GTA VI Mobile)

Jogo mobile em mundo aberto 3D inspirado em **GTA VI** (Vice Beach & Estado de Leonida), rodando 100% offline em **HTML + CSS + JavaScript + Three.js** e empacotado em APK Android nativo (`vice-game/android`).

## Destaques da Jogabilidade

- **Mundo Aberto 3D (Vice Leonida)**:
- **Ocean Drive & Vice Beach**: hotéis Art Déco iluminados em neon, palmeiras, areia branca, guarda-sóis, ondas do Atlântico e Píer.
- **Washington Strip & Midtown**: comércio, avenidas largas, cruzamentos sinalizados e Oficinas *Neon Customs* (Pay & Spray).
- **Canal de Biscayne & Downtown Leonida**: pontes iluminadas ligando a ilha costeira aos arranha-céus corporativos, Banco Nacional e Distrito Portuário de Gellhorn.
- **Ciclo Atmosférico**: dia tropical, pôr do sol rosa/laranja característico de Leonida e noite neon.
- **Dupla de Protagonistas**: alterne a qualquer momento entre **Lucia Caminos** e **Jason Duval**.
- **Física de Veículos & Tráfego**:
- Supercarros (*Infernus Vice GT*), conversíveis (*Banshee Ocean Cabrio*), muscle V8 (*Dominator*), SUVs, táxis, motos (*NRG-600*) e viaturas *VCPD Interceptor*.
- Aceleração, freio/ré, derrapagem com freio de mão (*drift*), dano com fumaça e reparo/pintura nas oficinas.
- **Sistema Policial VCPD (1 a 5 ★)**: viaturas com giroflex e sirene sintetizada perseguem o jogador; despiste fugindo do raio visual ou pintando o carro numa oficina.
- **Rádio FM Sintetizada em Tempo Real (WebAudio)**: 4 estações procedurais (*Flash Neon 86.6*, *Sol Caliente 98.3*, *Leonida Bass 104.9* e *Vice Sunset 91.1*) sem depender de internet.
- **Campanha de Missões**: 4 capítulos jogáveis com rota GPS no minimapa, corridas contra o relógio e o *Grande Golpe de Leonida*.
- **Controles Mobile & Desktop**:
- **Touch (Android/iOS)**: analógico esquerdo, zona livre de rotação de câmera 360°, botões dedicados a pé (Atirar, Correr, Pular, Entrar) e no volante (Acelerar, Freio/Ré, Drift, Buzina, Sair).
- **Teclado (PC)**: `WASD`/Setas, `F` ou `E` (entrar/sair do veículo), `Espaço` (pulo / freio de mão), `Shift` (sprint), `J` (atirar), `Q` (arma), `R` (rádio FM), `C` (trocar Lucia/Jason), `M` (mapa GPS), `Esc`/`P` (pausa).

## Como rodar localmente

```bash
# Servidor local (abre em http://0.0.0.0:8090)
node vice-game/serve.mjs --port 8090

# Gerar bundle offline (file://)
node vice-game/tools/build-bundle.mjs

# Rodar suíte de testes automatizados
node --test tests/vice-game.test.mjs

# Compilar APK Android isolado
./gradlew -p vice-game/android assembleRelease
```
67 changes: 67 additions & 0 deletions vice-game/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apply plugin: 'com.android.application'

// Casca Android nativa de VICE VI Mobile: empacota o jogo (HTML/CSS/JS + three.js)
// dentro dos assets do APK e o serve offline em paisagem com aceleração de hardware.

def gameRoot = file('../../')
def stagedAssets = layout.buildDirectory.dir('generated/gameAssets')

android {
compileSdk = 35
namespace = 'com.nextvr.vice6'

defaultConfig {
applicationId "com.nextvr.vice6"
minSdkVersion 26
targetSdkVersion 35
versionCode 2
versionName "0.2.0"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

signingConfigs {
debug {
storeFile rootProject.file('../../signing/debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}

buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
signingConfig signingConfigs.debug
}
}

sourceSets {
main {
assets.srcDirs = [stagedAssets.get().asFile]
}
}
}

tasks.register('stageGameAssets', Copy) {
from(gameRoot) {
include 'index.html'
include 'upload-glb.html'
include 'styles/**'
include 'src/**'
include 'assets/**'
include 'vendor/**'
exclude '**/.DS_Store'
}
into stagedAssets.map { it.dir('game') }
}

tasks.named('preBuild') {
dependsOn 'stageGameAssets'
}
Loading